結果
問題 | No.2422 regisys? |
ユーザー |
![]() |
提出日時 | 2025-03-31 17:34:46 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,862 bytes |
コンパイル時間 | 137 ms |
コンパイル使用メモリ | 82,356 KB |
実行使用メモリ | 190,560 KB |
最終ジャッジ日時 | 2025-03-31 17:35:41 |
合計ジャッジ時間 | 15,025 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 50 WA * 11 |
ソースコード
import bisectdef main():import sysinput = sys.stdin.readdata = input().split()idx = 0N = int(data[idx])M = int(data[idx+1])idx +=2A = list(map(int, data[idx:idx+N]))idx +=NB = list(map(int, data[idx:idx+N]))idx +=Nt0 = []t1 = []for _ in range(M):T = int(data[idx])C = int(data[idx+1])idx +=2if T == 0:t0.append(C)else:t1.append(C)# Sort the buyers' listst0.sort()t1.sort()# Prepare products with their min_p, preferred type, a, bproducts = []for i in range(N):a = A[i]b = B[i]min_p = min(a, b)preferred = 0 if a <= b else 1products.append( (min_p, preferred, a, b) )# Sort products by min_pproducts.sort(key=lambda x: x[0])ptr0 = 0ptr1 = 0count = 0for p in products:min_p, preferred, a, b = pif preferred == 0:# Try T0 firstidx0 = bisect.bisect_left(t0, a, ptr0)if idx0 < len(t0):count +=1ptr0 = idx0 +1else:# Try T1's B priceidx1 = bisect.bisect_left(t1, b, ptr1)if idx1 < len(t1):count +=1ptr1 = idx1 +1else:# Try T1 firstidx1 = bisect.bisect_left(t1, b, ptr1)if idx1 < len(t1):count +=1ptr1 = idx1 +1else:# Try T0's A priceidx0 = bisect.bisect_left(t0, a, ptr0)if idx0 < len(t0):count +=1ptr0 = idx0 +1print(N - count)if __name__ == "__main__":main()