結果
問題 | No.2422 regisys? |
ユーザー | sepa38 |
提出日時 | 2023-07-15 15:02:17 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,838 bytes |
コンパイル時間 | 138 ms |
コンパイル使用メモリ | 81,876 KB |
実行使用メモリ | 154,628 KB |
最終ジャッジ日時 | 2024-09-16 23:56:54 |
合計ジャッジ時間 | 20,877 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
53,436 KB |
testcase_01 | AC | 37 ms
53,340 KB |
testcase_02 | RE | - |
testcase_03 | AC | 40 ms
54,044 KB |
testcase_04 | RE | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 42 ms
55,040 KB |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 37 ms
53,332 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 38 ms
55,492 KB |
testcase_16 | RE | - |
testcase_17 | AC | 36 ms
53,556 KB |
testcase_18 | RE | - |
testcase_19 | WA | - |
testcase_20 | RE | - |
testcase_21 | AC | 35 ms
53,688 KB |
testcase_22 | RE | - |
testcase_23 | AC | 39 ms
55,932 KB |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | AC | 36 ms
53,724 KB |
testcase_31 | RE | - |
testcase_32 | WA | - |
testcase_33 | RE | - |
testcase_34 | WA | - |
testcase_35 | RE | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 340 ms
85,640 KB |
testcase_40 | RE | - |
testcase_41 | WA | - |
testcase_42 | RE | - |
testcase_43 | AC | 711 ms
98,788 KB |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | WA | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | WA | - |
testcase_57 | AC | 1,822 ms
154,496 KB |
testcase_58 | AC | 1,853 ms
154,628 KB |
testcase_59 | AC | 1,849 ms
154,136 KB |
testcase_60 | AC | 1,854 ms
154,392 KB |
testcase_61 | AC | 34 ms
54,700 KB |
ソースコード
import heapq n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ls = [list(map(int, input().split())) for _ in range(n)] def solve(n, m, a, b, ls): a2 = [[a[i], i] for i in range(n)] b2 = [[b[i], i] for i in range(n)] a2.sort() b2.sort() ls.sort(key = lambda x: x[1]) flg = [0] * n h1 = [] h2 = [] idxa = 0 idxb = 0 for t, c in ls: while idxa < n: if a2[idxa][0] > c: break idx = a2[idxa][1] heapq.heappush(h1, (-b[idx])*n+idx) idxa += 1 while idxb < n: if b2[idxb][0] > c: break idx = b2[idxb][1] heapq.heappush(h2, (-a[idx])*n+idx) idxb += 1 if t: while h2: tmp = heapq.heappop(h2) x, i = divmod(tmp, n) if flg[i] == 0: flg[i] = 1 break else: while h1: tmp = heapq.heappop(h1) x, i = divmod(tmp, n) if flg[i] == 0: flg[i] = 1 break # print(flg, t, c) # print(h1, h2) return n - sum(flg) # print(flg) from itertools import permutations def naive(n, m, a, b, ls): ans = n for p in permutations(range(m)): res = n for i in range(m): t, c = ls[i] if t: res -= b[p[i]] <= c else: res -= a[p[i]] <= c ans = min(ans, res) return ans print(solve(n, m, a, b, ls)) # print(naive(n, m, a, b, ls)) exit() import random for _ in range(10): n, m = random.randint(3, 5), random.randint(3, 5) m = max(m, n) a = [random.randint(1, 10) for _ in range(n)] b = [random.randint(1, 10) for _ in range(n)] ls = [[random.randint(0, 1), random.randint(1, 10)] for _ in range(m)] if solve(n, m, a, b, ls) != naive(n, m, a, b, ls): print(n, m) print(*a) print(*b) for t, c in ls: print(t, c) break