Submission #1955534
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 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 | 500 |
Code Size | 1084 Byte |
Status | AC |
Exec Time | 759 ms |
Memory | 66660 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 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 | AC | 567 ms | 60684 KB |
001.txt | AC | 395 ms | 47708 KB |
002.txt | AC | 420 ms | 46848 KB |
003.txt | AC | 438 ms | 46708 KB |
004.txt | AC | 745 ms | 62144 KB |
005.txt | AC | 729 ms | 63896 KB |
006.txt | AC | 747 ms | 63576 KB |
007.txt | AC | 710 ms | 64232 KB |
008.txt | AC | 759 ms | 66660 KB |
009.txt | AC | 700 ms | 65908 KB |
010.txt | AC | 752 ms | 64932 KB |
011.txt | AC | 717 ms | 63492 KB |
example0.txt | AC | 96 ms | 21076 KB |
example1.txt | AC | 96 ms | 16980 KB |