結果

問題 No.2422 regisys?
ユーザー gr1msl3y
提出日時 2023-08-16 16:03:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 796 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 82,284 KB
実行使用メモリ 132,768 KB
最終ジャッジ日時 2024-11-25 05:47:44
合計ジャッジ時間 18,702 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq as hq
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
task = [[] for _ in range(2)]
for _ in range(M):
    t, v = map(int, input().split())
    task[t].append(v)

for i in range(2):
    task[i].sort()

state = []
seen = [0]*N
Aind = sorted(list(range(N)), key=lambda x: A[x])
ind = 0
for v in task[0]:
    while ind < N and v >= A[Aind[ind]]:
        hq.heappush(state, [-B[Aind[ind]], Aind[ind]])
        ind += 1
    if state:
        w, t = hq.heappop(state)
        seen[t] = 1

ans = N-sum(seen)
Bval = [B[i] for i in range(N) if not seen[i]]
Bval.sort()
ind = 0
for i, v in enumerate(task[1]):
    if Bval and v >= Bval[0]:
        hq.heappop(Bval)
        ans -= 1

print(ans)
0