結果
| 問題 | No.2422 regisys? |
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2023-08-12 14:59:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,081 ms / 2,000 ms |
| コード長 | 695 bytes |
| 記録 | |
| コンパイル時間 | 671 ms |
| コンパイル使用メモリ | 81,976 KB |
| 実行使用メモリ | 132,472 KB |
| 最終ジャッジ日時 | 2024-11-19 22:34:17 |
| 合計ジャッジ時間 | 23,984 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 61 |
ソースコード
from sys import stdin
input=lambda :stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
t0=[]
t1=[]
for i in range(m):
t,c=map(int,input().split())
if t:
t1.append(c)
else:
t0.append(c)
t0.sort()
t1.sort()
from heapq import heappop, heappush
ab=[]
for i in range(n):
ab.append([a[i],b[i]])
ab.sort()
idx=0
hq=[]
ans=0
for c in t0:
while idx!=n and ab[idx][0]<=c:
heappush(hq,-ab[idx][1])
idx+=1
if hq:
ans+=1
heappop(hq)
while idx!=n:
heappush(hq,-ab[idx][1])
idx+=1
hq2=[]
for i in hq:
heappush(hq2,-i)
for c in t1:
if hq2 and hq2[0]<=c:
heappop(hq2)
ans+=1
print(n-ans)
とりゐ