結果
問題 | No.2422 regisys? |
ユーザー | sepa38 |
提出日時 | 2023-07-15 15:05:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,917 ms / 2,000 ms |
コード長 | 1,885 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 81,664 KB |
実行使用メモリ | 154,632 KB |
最終ジャッジ日時 | 2024-09-17 00:00:55 |
合計ジャッジ時間 | 34,945 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
52,992 KB |
testcase_01 | AC | 39 ms
53,760 KB |
testcase_02 | AC | 40 ms
53,632 KB |
testcase_03 | AC | 37 ms
53,504 KB |
testcase_04 | AC | 36 ms
53,888 KB |
testcase_05 | AC | 37 ms
54,016 KB |
testcase_06 | AC | 38 ms
54,528 KB |
testcase_07 | AC | 36 ms
54,272 KB |
testcase_08 | AC | 42 ms
54,400 KB |
testcase_09 | AC | 39 ms
53,120 KB |
testcase_10 | AC | 39 ms
53,248 KB |
testcase_11 | AC | 41 ms
53,632 KB |
testcase_12 | AC | 39 ms
52,480 KB |
testcase_13 | AC | 41 ms
54,016 KB |
testcase_14 | AC | 35 ms
53,120 KB |
testcase_15 | AC | 37 ms
54,272 KB |
testcase_16 | AC | 35 ms
53,504 KB |
testcase_17 | AC | 37 ms
53,760 KB |
testcase_18 | AC | 36 ms
52,864 KB |
testcase_19 | AC | 38 ms
53,760 KB |
testcase_20 | AC | 39 ms
54,400 KB |
testcase_21 | AC | 36 ms
53,376 KB |
testcase_22 | AC | 36 ms
53,248 KB |
testcase_23 | AC | 38 ms
54,144 KB |
testcase_24 | AC | 36 ms
53,376 KB |
testcase_25 | AC | 37 ms
53,120 KB |
testcase_26 | AC | 37 ms
53,120 KB |
testcase_27 | AC | 36 ms
53,760 KB |
testcase_28 | AC | 35 ms
53,504 KB |
testcase_29 | AC | 34 ms
53,376 KB |
testcase_30 | AC | 35 ms
52,992 KB |
testcase_31 | AC | 592 ms
102,520 KB |
testcase_32 | AC | 827 ms
108,280 KB |
testcase_33 | AC | 563 ms
102,016 KB |
testcase_34 | AC | 385 ms
92,464 KB |
testcase_35 | AC | 683 ms
109,368 KB |
testcase_36 | AC | 685 ms
100,980 KB |
testcase_37 | AC | 947 ms
109,508 KB |
testcase_38 | AC | 542 ms
99,356 KB |
testcase_39 | AC | 415 ms
93,056 KB |
testcase_40 | AC | 396 ms
89,760 KB |
testcase_41 | AC | 506 ms
95,596 KB |
testcase_42 | AC | 1,144 ms
127,124 KB |
testcase_43 | AC | 695 ms
100,724 KB |
testcase_44 | AC | 1,258 ms
130,152 KB |
testcase_45 | AC | 1,031 ms
122,104 KB |
testcase_46 | AC | 1,283 ms
131,040 KB |
testcase_47 | AC | 875 ms
111,412 KB |
testcase_48 | AC | 1,272 ms
139,032 KB |
testcase_49 | AC | 1,067 ms
121,060 KB |
testcase_50 | AC | 1,198 ms
135,404 KB |
testcase_51 | AC | 1,615 ms
146,232 KB |
testcase_52 | AC | 559 ms
103,128 KB |
testcase_53 | AC | 1,276 ms
127,628 KB |
testcase_54 | AC | 1,590 ms
150,128 KB |
testcase_55 | AC | 1,281 ms
130,808 KB |
testcase_56 | AC | 950 ms
128,324 KB |
testcase_57 | AC | 1,851 ms
154,264 KB |
testcase_58 | AC | 1,917 ms
154,248 KB |
testcase_59 | AC | 1,859 ms
154,632 KB |
testcase_60 | AC | 1,865 ms
153,992 KB |
testcase_61 | AC | 37 ms
52,992 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(m)] 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(100): n, m = random.randint(1, 5), random.randint(1, 5) # m = max(m, n) a = [random.randint(1, 10**9) for _ in range(n)] b = [random.randint(1, 10**9) for _ in range(n)] ls = [[random.randint(0, 1), random.randint(1, 10**9)] for _ in range(m)] solve(n, m, a, b, ls) continue 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