結果

問題 No.2422 regisys?
ユーザー pありpあり
提出日時 2023-08-12 15:13:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,861 ms / 2,000 ms
コード長 952 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 148,064 KB
最終ジャッジ日時 2024-04-30 08:30:16
合計ジャッジ時間 34,127 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,552 KB
testcase_01 AC 34 ms
55,192 KB
testcase_02 AC 36 ms
55,496 KB
testcase_03 AC 35 ms
54,000 KB
testcase_04 AC 34 ms
54,448 KB
testcase_05 AC 37 ms
54,796 KB
testcase_06 AC 39 ms
55,364 KB
testcase_07 AC 37 ms
54,292 KB
testcase_08 AC 36 ms
55,196 KB
testcase_09 AC 36 ms
54,888 KB
testcase_10 AC 34 ms
54,796 KB
testcase_11 AC 34 ms
54,856 KB
testcase_12 AC 33 ms
53,024 KB
testcase_13 AC 36 ms
56,484 KB
testcase_14 AC 36 ms
54,116 KB
testcase_15 AC 38 ms
54,712 KB
testcase_16 AC 34 ms
54,272 KB
testcase_17 AC 35 ms
54,264 KB
testcase_18 AC 34 ms
54,236 KB
testcase_19 AC 36 ms
55,976 KB
testcase_20 AC 37 ms
55,868 KB
testcase_21 AC 35 ms
55,448 KB
testcase_22 AC 35 ms
53,672 KB
testcase_23 AC 36 ms
56,056 KB
testcase_24 AC 34 ms
55,340 KB
testcase_25 AC 34 ms
55,052 KB
testcase_26 AC 33 ms
52,952 KB
testcase_27 AC 38 ms
54,380 KB
testcase_28 AC 36 ms
54,220 KB
testcase_29 AC 35 ms
54,484 KB
testcase_30 AC 36 ms
54,248 KB
testcase_31 AC 594 ms
98,652 KB
testcase_32 AC 872 ms
94,028 KB
testcase_33 AC 559 ms
98,772 KB
testcase_34 AC 396 ms
84,232 KB
testcase_35 AC 666 ms
109,212 KB
testcase_36 AC 629 ms
93,628 KB
testcase_37 AC 923 ms
97,276 KB
testcase_38 AC 607 ms
90,040 KB
testcase_39 AC 463 ms
84,704 KB
testcase_40 AC 391 ms
89,944 KB
testcase_41 AC 502 ms
86,592 KB
testcase_42 AC 1,089 ms
135,468 KB
testcase_43 AC 706 ms
92,984 KB
testcase_44 AC 1,186 ms
132,464 KB
testcase_45 AC 998 ms
127,124 KB
testcase_46 AC 1,181 ms
136,448 KB
testcase_47 AC 856 ms
104,252 KB
testcase_48 AC 1,203 ms
144,820 KB
testcase_49 AC 1,032 ms
116,928 KB
testcase_50 AC 1,078 ms
148,064 KB
testcase_51 AC 1,542 ms
136,444 KB
testcase_52 AC 556 ms
101,560 KB
testcase_53 AC 1,164 ms
132,576 KB
testcase_54 AC 1,548 ms
144,068 KB
testcase_55 AC 1,205 ms
130,476 KB
testcase_56 AC 1,001 ms
110,472 KB
testcase_57 AC 1,822 ms
140,960 KB
testcase_58 AC 1,791 ms
141,068 KB
testcase_59 AC 1,861 ms
141,332 KB
testcase_60 AC 1,759 ms
141,092 KB
testcase_61 AC 34 ms
53,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n,m = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.append(10**10)
b.append(10**10)
n+=1

aa = []
bb = []
for i in range(n):
  aa.append((a[i], i))
  bb.append((b[i], i))
  
aa.sort()
bb.sort() 
ok = [1 for _ in range(n)]


tt = []
for _ in range(m):
  t,c = map(int, input().split())
  tt.append((c, t))
  
tt.sort()

anow = 0
ha = []
bnow = 0
hb = []

for c,t in tt:
  #print(c,t)
  
  if(t==0):
    while(aa[anow][0] <= c):
      heapq.heappush(ha, (-b[aa[anow][1]], aa[anow][1]))
      anow+=1
      
    while(ha):
      _, i = heapq.heappop(ha)
      if(ok[i]==1):
        ok[i]=0
        #print(i)
        break
      
      
  else:
    while(bb[bnow][0] <= c):
      heapq.heappush(hb, (-a[bb[bnow][1]], bb[bnow][1]))
      bnow+=1
    while(hb):
      _, i = heapq.heappop(hb)
      if(ok[i]==1):
        ok[i]=0
        #print(i)
        break
  
        
print(sum(ok)-1)
0