Submission #5000520


Source Code Expand

# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
AB=[(INT(), 'pc') for i in range(N)]+[(INT(), 'plug') for i in range(N)]
AB.sort()

C=Counter()
ans=1
for i in range(N*2):
    a,_type=AB[i]
    if C['pc']==C['plug']:
        C[_type]+=1
    elif C['pc']>C['plug']:
        if _type=='pc':
            C['pc']+=1
        else:
            ans=(ans*C['pc'])%MOD
            C['pc']-=1
    elif C['pc']<C['plug']:
        if _type=='plug':
            C['plug']+=1
        else:
            ans=(ans*C['plug'])%MOD
            C['plug']-=1
print(ans)

Submission Info

Submission Time
Task A - 1D Matching
User Coki628
Language Python (3.4.3)
Score 500
Code Size 1131 Byte
Status AC
Exec Time 775 ms
Memory 25656 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 441 ms 16836 KB
001.txt AC 148 ms 8288 KB
002.txt AC 212 ms 10188 KB
003.txt AC 230 ms 11060 KB
004.txt AC 659 ms 23256 KB
005.txt AC 760 ms 25652 KB
006.txt AC 746 ms 25652 KB
007.txt AC 708 ms 25656 KB
008.txt AC 761 ms 25652 KB
009.txt AC 685 ms 25564 KB
010.txt AC 775 ms 25636 KB
011.txt AC 681 ms 25640 KB
example0.txt AC 22 ms 3316 KB
example1.txt AC 22 ms 3316 KB