結果
問題 |
No.2422 regisys?
|
ユーザー |
👑 ![]() |
提出日時 | 2023-08-23 07:59:22 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,295 bytes |
コンパイル時間 | 292 ms |
コンパイル使用メモリ | 82,540 KB |
実行使用メモリ | 151,720 KB |
最終ジャッジ日時 | 2024-12-21 09:02:00 |
合計ジャッジ時間 | 37,946 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 60 TLE * 1 |
ソースコード
""" とりあえず、小さい方から見る すると、自分が買わなかったものは後の人が買えるので、どれを選んでもOK 後は、相手側の一番高い物を買えばよい…? """ import sys from sys import stdin import heapq N,M = map(int,stdin.readline().split()) A = list(map(int,stdin.readline().split())) B = list(map(int,stdin.readline().split())) CT = [] for i in range(M): T,C = map(int,stdin.readline().split()) CT.append( (C,T) ) CT.sort() able = [True] * N AtoB = [(A[i],B[i],i) for i in range(N)] AtoB.sort(); AtoB.reverse() BtoA = [(B[i],A[i],i) for i in range(N)] BtoA.sort(); BtoA.reverse() q0 = [] q1 = [] ans = N for C,T in CT: if T == 0: while AtoB and AtoB[-1][0] <= C: na,nb,i = AtoB.pop() heapq.heappush( q0 , (-nb,i) ) while q0: mnb,i = heapq.heappop(q0) if able[i]: able[i] = False ans -= 1 break else: while BtoA and BtoA[-1][0] <= C: nb,na,i = BtoA.pop() heapq.heappush( q1, (-na,i) ) while q1: mna,i = heapq.heappop(q1) if able[i]: able[i] = False ans -= 1 break print (ans)