Submission #1955537
Source Code Expand
import java.util.Arrays; import java.util.Scanner; class Main { int n; final long MOD = 1_000_000_000 + 7; void run() { Scanner sc = new Scanner(System.in); n = sc.nextInt(); long[] c = new long[2 * n]; for (int i = 0; i < n; ++i) { c[2 * i] = 2 * sc.nextInt(); c[2 * i + 1] = 2 * sc.nextInt() + 1; } Arrays.sort(c); int out = 0, in = 0; long ans = 1; for (int i = 0; i < 2 * n; ++i) { if (c[i] % 2 == 1) {// outlet ++out; } else {// pc ++in; } while (out > 0 && in > 0) { ans = ans * Math.max(out, in) % MOD; --out; --in; } } if (out != 0 || in != 0) throw new AssertionError(); System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } public static void main(String[] args) { new Main().run(); } }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | fortoobye |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 876 Byte |
Status | WA |
Exec Time | 694 ms |
Memory | 87792 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | WA | 553 ms | 60020 KB |
001.txt | WA | 375 ms | 46048 KB |
002.txt | WA | 431 ms | 44628 KB |
003.txt | WA | 425 ms | 46072 KB |
004.txt | WA | 694 ms | 62652 KB |
005.txt | WA | 650 ms | 64892 KB |
006.txt | WA | 651 ms | 64260 KB |
007.txt | WA | 645 ms | 87792 KB |
008.txt | WA | 632 ms | 63812 KB |
009.txt | WA | 641 ms | 62224 KB |
010.txt | WA | 685 ms | 87404 KB |
011.txt | WA | 653 ms | 65596 KB |
example0.txt | WA | 96 ms | 21588 KB |
example1.txt | AC | 97 ms | 19028 KB |