結果

問題 No.2422 regisys?
ユーザー titiatitia
提出日時 2023-08-22 03:02:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 847 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 979 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 144,744 KB
最終ジャッジ日時 2023-08-22 03:03:11
合計ジャッジ時間 22,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,428 KB
testcase_01 AC 73 ms
71,472 KB
testcase_02 AC 76 ms
75,512 KB
testcase_03 AC 74 ms
71,472 KB
testcase_04 AC 77 ms
75,624 KB
testcase_05 AC 73 ms
71,472 KB
testcase_06 AC 76 ms
71,100 KB
testcase_07 AC 74 ms
71,508 KB
testcase_08 AC 74 ms
71,240 KB
testcase_09 AC 76 ms
71,404 KB
testcase_10 AC 88 ms
71,384 KB
testcase_11 AC 76 ms
71,236 KB
testcase_12 AC 74 ms
71,412 KB
testcase_13 AC 78 ms
71,268 KB
testcase_14 AC 76 ms
71,380 KB
testcase_15 AC 74 ms
71,244 KB
testcase_16 AC 77 ms
74,968 KB
testcase_17 AC 87 ms
71,556 KB
testcase_18 AC 77 ms
75,592 KB
testcase_19 AC 76 ms
71,240 KB
testcase_20 AC 75 ms
71,240 KB
testcase_21 AC 72 ms
71,328 KB
testcase_22 AC 88 ms
71,092 KB
testcase_23 AC 75 ms
71,328 KB
testcase_24 AC 76 ms
71,240 KB
testcase_25 AC 81 ms
75,676 KB
testcase_26 AC 72 ms
71,520 KB
testcase_27 AC 74 ms
71,328 KB
testcase_28 AC 75 ms
71,104 KB
testcase_29 AC 78 ms
75,564 KB
testcase_30 AC 74 ms
71,460 KB
testcase_31 AC 407 ms
96,140 KB
testcase_32 AC 384 ms
93,964 KB
testcase_33 AC 384 ms
95,780 KB
testcase_34 AC 236 ms
82,464 KB
testcase_35 AC 461 ms
101,376 KB
testcase_36 AC 319 ms
87,896 KB
testcase_37 AC 428 ms
96,384 KB
testcase_38 AC 296 ms
85,024 KB
testcase_39 AC 238 ms
84,000 KB
testcase_40 AC 291 ms
89,564 KB
testcase_41 AC 275 ms
84,140 KB
testcase_42 AC 691 ms
137,876 KB
testcase_43 AC 371 ms
93,636 KB
testcase_44 AC 721 ms
136,160 KB
testcase_45 AC 592 ms
129,256 KB
testcase_46 AC 699 ms
136,928 KB
testcase_47 AC 454 ms
99,212 KB
testcase_48 AC 780 ms
138,052 KB
testcase_49 AC 515 ms
116,384 KB
testcase_50 AC 722 ms
138,384 KB
testcase_51 AC 784 ms
137,888 KB
testcase_52 AC 400 ms
99,156 KB
testcase_53 AC 768 ms
135,868 KB
testcase_54 AC 847 ms
144,744 KB
testcase_55 AC 788 ms
133,368 KB
testcase_56 AC 491 ms
112,256 KB
testcase_57 AC 784 ms
133,980 KB
testcase_58 AC 814 ms
133,996 KB
testcase_59 AC 786 ms
133,872 KB
testcase_60 AC 778 ms
133,888 KB
testcase_61 AC 77 ms
71,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from operator import itemgetter
from heapq import heappop,heappush

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

AB=[]

for i in range(N):
    AB.append((A[i],B[i]))

C0=[]
C1=[]

for i in range(M):
    t,c=map(int,input().split())
    if t==0:
        C0.append(c)
    else:
        C1.append(c)

C0.sort()
C1.sort()



#AB.sort(key=itemgetter(1),reverse=True)
AB.sort(key=itemgetter(0))

H=[]

ind=0
for i in range(len(C0)):
    c=C0[i]
    while ind<N and AB[ind][0]<=c:
        a,b=AB[ind]
        heappush(H,(-b,a))
        ind+=1

    #print(H,c)

    if H:
        heappop(H)

for i in range(ind,N):
    a,b=AB[i]
    heappush(H,(-b,a))

C1rest=[]

while H:
    a,b=heappop(H)
    C1rest.append(-a)

C1rest.sort()

H=[]
ind=0
for i in range(len(C1)):
    c=C1[i]
    while ind<len(C1rest) and C1rest[ind]<=c:
        heappush(H,-C1rest[ind])
        ind+=1

    if H:
        heappop(H)

for i in range(ind,len(C1rest)):
    heappush(H,-C1rest[i])


print(len(H))
0