結果
問題 |
No.2422 regisys?
|
ユーザー |
![]() |
提出日時 | 2023-08-22 03:02:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 670 ms / 2,000 ms |
コード長 | 1,061 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 148,712 KB |
最終ジャッジ日時 | 2024-12-15 20:15:06 |
合計ジャッジ時間 | 19,247 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 61 |
ソースコード
import sys input = sys.stdin.readline from operator import itemgetter from heapq import heappop,heappush N,M=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) AB=[] for i in range(N): AB.append((A[i],B[i])) C0=[] C1=[] for i in range(M): t,c=map(int,input().split()) if t==0: C0.append(c) else: C1.append(c) C0.sort() C1.sort() #AB.sort(key=itemgetter(1),reverse=True) AB.sort(key=itemgetter(0)) H=[] ind=0 for i in range(len(C0)): c=C0[i] while ind<N and AB[ind][0]<=c: a,b=AB[ind] heappush(H,(-b,a)) ind+=1 #print(H,c) if H: heappop(H) for i in range(ind,N): a,b=AB[i] heappush(H,(-b,a)) C1rest=[] while H: a,b=heappop(H) C1rest.append(-a) C1rest.sort() H=[] ind=0 for i in range(len(C1)): c=C1[i] while ind<len(C1rest) and C1rest[ind]<=c: heappush(H,-C1rest[ind]) ind+=1 if H: heappop(H) for i in range(ind,len(C1rest)): heappush(H,-C1rest[i]) print(len(H))