Submission #1955507
Source Code Expand
import java.util.Arrays; import java.util.Scanner; class Main { int n; int[] a; int[] b; final long MOD = 1_000_000_000 + 7; void run() { Scanner sc = new Scanner(System.in); n = sc.nextInt(); a = new int[n]; b = new int[n]; for (int i = 0; i < n; ++i) { a[i] = sc.nextInt(); } for (int i = 0; i < n; ++i) { b[i] = sc.nextInt(); } Arrays.sort(a); Arrays.sort(b); long[] c = new long[2 * n]; for (int i = 0; i < n; ++i) { c[2 * i] = 2 * a[i]; c[2 * i + 1] = 2 * b[i] + 1; } Arrays.sort(c); int p = 0, q = 0; long ans = 1; for (int i = 0; i < 2 * n; ++i) { if (c[i] % 2 == 1) {// outlet if (p == 0) { ++q; } else { ans = ans * p % MOD; --p; } } else {// pc if (q == 0) ++p; else { --q; } } } 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 | 1044 Byte |
Status | WA |
Exec Time | 759 ms |
Memory | 64728 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 | 563 ms | 60508 KB |
001.txt | WA | 390 ms | 46268 KB |
002.txt | WA | 432 ms | 46948 KB |
003.txt | WA | 501 ms | 45132 KB |
004.txt | WA | 625 ms | 60656 KB |
005.txt | WA | 641 ms | 64728 KB |
006.txt | WA | 735 ms | 60628 KB |
007.txt | WA | 724 ms | 63884 KB |
008.txt | WA | 712 ms | 64212 KB |
009.txt | WA | 677 ms | 62456 KB |
010.txt | WA | 759 ms | 63628 KB |
011.txt | AC | 705 ms | 64288 KB |
example0.txt | AC | 95 ms | 23636 KB |
example1.txt | AC | 96 ms | 20948 KB |