結果
問題 | No.2686 商品券の使い道 |
ユーザー | Shirotsume |
提出日時 | 2024-03-20 21:24:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,533 ms / 3,000 ms |
コード長 | 1,179 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 82,160 KB |
実行使用メモリ | 93,440 KB |
最終ジャッジ日時 | 2024-09-30 07:11:19 |
合計ジャッジ時間 | 38,954 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
55,552 KB |
testcase_01 | AC | 46 ms
55,424 KB |
testcase_02 | AC | 289 ms
81,024 KB |
testcase_03 | AC | 296 ms
81,152 KB |
testcase_04 | AC | 303 ms
81,152 KB |
testcase_05 | AC | 285 ms
80,896 KB |
testcase_06 | AC | 290 ms
80,768 KB |
testcase_07 | AC | 286 ms
81,152 KB |
testcase_08 | AC | 283 ms
80,768 KB |
testcase_09 | AC | 294 ms
80,768 KB |
testcase_10 | AC | 298 ms
80,768 KB |
testcase_11 | AC | 302 ms
81,152 KB |
testcase_12 | AC | 277 ms
81,280 KB |
testcase_13 | AC | 261 ms
81,152 KB |
testcase_14 | AC | 276 ms
80,768 KB |
testcase_15 | AC | 310 ms
81,280 KB |
testcase_16 | AC | 291 ms
81,152 KB |
testcase_17 | AC | 305 ms
81,024 KB |
testcase_18 | AC | 295 ms
81,152 KB |
testcase_19 | AC | 297 ms
81,280 KB |
testcase_20 | AC | 276 ms
81,024 KB |
testcase_21 | AC | 289 ms
81,152 KB |
testcase_22 | AC | 299 ms
81,408 KB |
testcase_23 | AC | 288 ms
81,408 KB |
testcase_24 | AC | 296 ms
80,896 KB |
testcase_25 | AC | 299 ms
81,152 KB |
testcase_26 | AC | 297 ms
81,280 KB |
testcase_27 | AC | 280 ms
81,024 KB |
testcase_28 | AC | 279 ms
81,152 KB |
testcase_29 | AC | 1,513 ms
93,312 KB |
testcase_30 | AC | 1,464 ms
93,056 KB |
testcase_31 | AC | 1,317 ms
93,440 KB |
testcase_32 | AC | 1,321 ms
93,312 KB |
testcase_33 | AC | 1,474 ms
93,184 KB |
testcase_34 | AC | 1,434 ms
93,312 KB |
testcase_35 | AC | 1,346 ms
93,440 KB |
testcase_36 | AC | 1,329 ms
93,312 KB |
testcase_37 | AC | 1,332 ms
93,312 KB |
testcase_38 | AC | 1,316 ms
93,056 KB |
testcase_39 | AC | 1,340 ms
93,312 KB |
testcase_40 | AC | 1,418 ms
93,312 KB |
testcase_41 | AC | 1,374 ms
93,312 KB |
testcase_42 | AC | 1,357 ms
93,312 KB |
testcase_43 | AC | 1,421 ms
93,440 KB |
testcase_44 | AC | 1,533 ms
93,312 KB |
testcase_45 | AC | 1,532 ms
93,440 KB |
testcase_46 | AC | 1,498 ms
93,440 KB |
evil_random20_1.txt | AC | 1,343 ms
93,184 KB |
evil_random20_2.txt | AC | 1,345 ms
93,312 KB |
evil_random20_3.txt | AC | 1,357 ms
93,184 KB |
ソースコード
import sys, time, random from collections import deque, Counter, defaultdict input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n, m, q = mi() AB = [li() for _ in range(20)] before = [0] * (1 << n) for bit in range(1 << n): value = 0 weight = 0 for i in range(n): if 1 & (bit >> i): value += AB[i][1] weight += AB[i][0] if weight <= m: before[bit] = value for bit in range(1 << n): for i in range(n): if (1 & (bit >> i)): before[bit] = max(before[bit ^ (1 << i)], before[bit]) after = [0] * (1 << n) for bit in range(1 << n): value = 0 weight = 0 for i in range(n): if 1 & (bit >> i): value += AB[i][1] weight += AB[i][0] if weight <= q: after[bit] = value for bit in range(1 << n): for i in range(n): if (1 & (bit >> i)): after[bit] = max(after[bit - (1 << i)], after[bit]) ans = 0 for bit in range(1 << n): ans = max(ans, before[bit] + after[(1 << n) - 1 - bit]) print(ans)