Submission #3276606


Source Code Expand

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
points = []
for i in range(N):
    a = int(input())
    points.append([a,True])
for i in range(N):
    b = int(input())
    points.append([b,False])
points.sort()

ans = 1
an = bn = 0
for x,c in points:
    if c:
        if bn > 0:
            ans = (ans*bn)%mod
            bn -= 1
        else:
            an += 1
    else:
        if an > 0:
            ans = (ans*an)%mod
            an -= 1
        else:
            bn += 1

print(ans%mod)

Submission Info

Submission Time
Task A - 1D Matching
User simamumu
Language Python (3.4.3)
Score 500
Code Size 772 Byte
Status AC
Exec Time 847 ms
Memory 31940 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 457 ms 21124 KB
001.txt AC 169 ms 10260 KB
002.txt AC 230 ms 12656 KB
003.txt AC 258 ms 13648 KB
004.txt AC 744 ms 28912 KB
005.txt AC 847 ms 31820 KB
006.txt AC 814 ms 31892 KB
007.txt AC 826 ms 31940 KB
008.txt AC 774 ms 31880 KB
009.txt AC 795 ms 31888 KB
010.txt AC 723 ms 31820 KB
011.txt AC 772 ms 31892 KB
example0.txt AC 29 ms 4208 KB
example1.txt AC 28 ms 4208 KB