結果
| 問題 | 
                            No.2422 regisys?
                             | 
                    
| コンテスト | |
| ユーザー | 
                             pあり
                         | 
                    
| 提出日時 | 2023-08-12 14:44:47 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,022 bytes | 
| コンパイル時間 | 314 ms | 
| コンパイル使用メモリ | 82,036 KB | 
| 実行使用メモリ | 147,948 KB | 
| 最終ジャッジ日時 | 2024-11-19 21:17:25 | 
| 合計ジャッジ時間 | 39,091 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 33 WA * 24 TLE * 4 | 
ソースコード
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==1):
    while(1):
      if(aa[anow][0] > c):
        break
      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(1):
      if(bb[bnow][0] > c):
        break
      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)
  
  
      
            
            
            
        
            
pあり