結果

問題 No.2422 regisys?
ユーザー とりゐとりゐ
提出日時 2023-08-12 14:59:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 891 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 132,908 KB
最終ジャッジ日時 2024-04-30 07:44:20
合計ジャッジ時間 19,115 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,228 KB
testcase_01 AC 34 ms
52,744 KB
testcase_02 AC 36 ms
53,188 KB
testcase_03 AC 34 ms
54,880 KB
testcase_04 AC 35 ms
53,752 KB
testcase_05 AC 35 ms
54,444 KB
testcase_06 AC 35 ms
54,988 KB
testcase_07 AC 34 ms
53,368 KB
testcase_08 AC 34 ms
53,228 KB
testcase_09 AC 36 ms
53,688 KB
testcase_10 AC 34 ms
54,424 KB
testcase_11 AC 36 ms
54,448 KB
testcase_12 AC 33 ms
53,220 KB
testcase_13 AC 34 ms
54,348 KB
testcase_14 AC 32 ms
53,304 KB
testcase_15 AC 35 ms
54,496 KB
testcase_16 AC 33 ms
53,744 KB
testcase_17 AC 32 ms
52,744 KB
testcase_18 AC 33 ms
54,736 KB
testcase_19 AC 34 ms
55,128 KB
testcase_20 AC 34 ms
53,972 KB
testcase_21 AC 33 ms
54,524 KB
testcase_22 AC 34 ms
53,292 KB
testcase_23 AC 35 ms
55,288 KB
testcase_24 AC 35 ms
53,668 KB
testcase_25 AC 36 ms
54,792 KB
testcase_26 AC 33 ms
53,236 KB
testcase_27 AC 33 ms
54,216 KB
testcase_28 AC 33 ms
52,948 KB
testcase_29 AC 35 ms
54,580 KB
testcase_30 AC 34 ms
54,344 KB
testcase_31 AC 327 ms
97,708 KB
testcase_32 AC 350 ms
92,488 KB
testcase_33 AC 329 ms
97,516 KB
testcase_34 AC 170 ms
81,748 KB
testcase_35 AC 377 ms
100,604 KB
testcase_36 AC 252 ms
87,096 KB
testcase_37 AC 399 ms
97,124 KB
testcase_38 AC 212 ms
85,428 KB
testcase_39 AC 175 ms
81,624 KB
testcase_40 AC 239 ms
87,816 KB
testcase_41 AC 211 ms
84,112 KB
testcase_42 AC 651 ms
109,576 KB
testcase_43 AC 305 ms
92,728 KB
testcase_44 AC 668 ms
111,832 KB
testcase_45 AC 561 ms
106,780 KB
testcase_46 AC 659 ms
111,340 KB
testcase_47 AC 410 ms
98,576 KB
testcase_48 AC 743 ms
115,420 KB
testcase_49 AC 484 ms
104,712 KB
testcase_50 AC 653 ms
114,176 KB
testcase_51 AC 721 ms
112,536 KB
testcase_52 AC 340 ms
98,776 KB
testcase_53 AC 669 ms
109,624 KB
testcase_54 AC 801 ms
132,908 KB
testcase_55 AC 697 ms
112,664 KB
testcase_56 AC 437 ms
103,952 KB
testcase_57 AC 873 ms
132,376 KB
testcase_58 AC 870 ms
132,108 KB
testcase_59 AC 891 ms
132,012 KB
testcase_60 AC 836 ms
132,012 KB
testcase_61 AC 34 ms
52,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0