Submission #11157631
Source Code Expand
N = int(input()) mod = int(1e9+7) def cmb(n, r): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n-r] % mod NMAX = 2*N + 5 fact = [0 for _ in range(NMAX)] factinv = [0 for _ in range(NMAX)] inv = [0 for _ in range(NMAX)] fact[0:2] = [1, 1] # fact[n] = (n! mod p) factinv[0:2] = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv[0:2] = [0, 1] # factinv 計算用 for i in range(2, NMAX): fact[i] = (fact[i-1] * i) % mod inv[i] = (-inv[mod % i] * (mod // i)) % mod factinv[i] = (factinv[i-1] * inv[i]) % mod A = [] for _ in range(N): A.append([int(input()),1]) for _ in range(N): A.append([int(input()),2]) A.sort() ans = 1 ca,cb = 0,0 prevN = 0 for a in A: if a[1] == 1: ca += 1 else: cb += 1 if ca == cb: wk = ca - prevN ans = ans * fact[wk] % mod prevN = ca print(ans)
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | mo2 |
Language | PyPy3 (2.4.0) |
Score | 0 |
Code Size | 923 Byte |
Status | WA |
Exec Time | 1482 ms |
Memory | 85580 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 | 972 ms | 70652 KB |
001.txt | WA | 516 ms | 55640 KB |
002.txt | WA | 610 ms | 59420 KB |
003.txt | WA | 657 ms | 60324 KB |
004.txt | WA | 1325 ms | 81912 KB |
005.txt | WA | 1463 ms | 85196 KB |
006.txt | WA | 1482 ms | 85452 KB |
007.txt | WA | 1453 ms | 85452 KB |
008.txt | WA | 1433 ms | 85324 KB |
009.txt | WA | 1447 ms | 85452 KB |
010.txt | AC | 1403 ms | 85580 KB |
011.txt | AC | 1462 ms | 85324 KB |
example0.txt | AC | 162 ms | 38256 KB |
example1.txt | AC | 163 ms | 38256 KB |