Submission #22101337


Source Code Expand

Copy
MOD = 10**9 + 7
N = int(input())
A = []
for _ in range(N):
    A.append((int(input()), "p"))

B = []
for _ in range(N):
    A.append((int(input()), "c"))

All = sorted(A+B)
P = 0
C = 0

ans = 1
for _, s in All:
    if s == "p":
        if C:
            ans *= C
            ans %= MOD
            C -= 1
        else:
            P += 1
    else:
        if P:
            ans *= P
            ans %= MOD
            P -= 1
        else:
            C += 1
print(ans)

Submission Info

Submission Time
Task A - 1D Matching
User shinitao
Language PyPy3 (7.3.0)
Score 500
Code Size 500 Byte
Status AC
Exec Time 714 ms
Memory 97352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 14
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 456 ms 86020 KB
001.txt AC 219 ms 75884 KB
002.txt AC 262 ms 76744 KB
003.txt AC 281 ms 78676 KB
004.txt AC 603 ms 95004 KB
005.txt AC 673 ms 96936 KB
006.txt AC 671 ms 97164 KB
007.txt AC 671 ms 97028 KB
008.txt AC 671 ms 96892 KB
009.txt AC 709 ms 96944 KB
010.txt AC 659 ms 96712 KB
011.txt AC 714 ms 97352 KB
example0.txt AC 55 ms 61880 KB
example1.txt AC 56 ms 61732 KB