結果
問題 |
No.2422 regisys?
|
ユーザー |
![]() |
提出日時 | 2025-03-26 15:52:54 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,338 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 82,736 KB |
実行使用メモリ | 133,252 KB |
最終ジャッジ日時 | 2025-03-26 15:53:49 |
合計ジャッジ時間 | 17,780 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 43 WA * 18 |
ソースコード
n, m = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) type0 = [] type1 = [] for _ in range(m): t, c = map(int, input().split()) if t == 0: type0.append(c) else: type1.append(c) # Sort products by A and keep original indices sorted_A = sorted([(A[i], i) for i in range(n)], key=lambda x: x[0]) # Sort products by B and keep original indices sorted_B = sorted([(B[i], i) for i in range(n)], key=lambda x: x[0]) sold = [False] * n count = 0 # Process type0 buyers (sorted descending) type0.sort(reverse=True) ptr_a = n - 1 # Start from the highest A for c in type0: while ptr_a >= 0: a_val, idx = sorted_A[ptr_a] if a_val <= c and not sold[idx]: sold[idx] = True count += 1 ptr_a -= 1 break else: ptr_a -= 1 else: break # No more products # Process type1 buyers (sorted descending) type1.sort(reverse=True) ptr_b = n - 1 # Start from the highest B for c in type1: while ptr_b >= 0: b_val, idx = sorted_B[ptr_b] if b_val <= c and not sold[idx]: sold[idx] = True count += 1 ptr_b -= 1 break else: ptr_b -= 1 else: break # No more products print(n - count)