結果
問題 | No.2686 商品券の使い道 |
ユーザー | Yakumo221 |
提出日時 | 2024-03-20 23:33:37 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,988 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 193,432 KB |
最終ジャッジ日時 | 2024-09-30 09:36:13 |
合計ジャッジ時間 | 47,961 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 40 ms
52,224 KB |
testcase_02 | AC | 470 ms
104,540 KB |
testcase_03 | AC | 437 ms
107,584 KB |
testcase_04 | WA | - |
testcase_05 | AC | 426 ms
115,252 KB |
testcase_06 | AC | 450 ms
105,028 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 423 ms
110,612 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 399 ms
105,612 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 368 ms
104,980 KB |
testcase_21 | AC | 440 ms
111,292 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 424 ms
114,084 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 1,482 ms
187,836 KB |
testcase_31 | WA | - |
testcase_32 | AC | 1,570 ms
173,824 KB |
testcase_33 | AC | 1,557 ms
189,432 KB |
testcase_34 | WA | - |
testcase_35 | AC | 1,567 ms
185,428 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 1,559 ms
177,936 KB |
testcase_39 | AC | 1,637 ms
166,904 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
evil_random20_1.txt | WA | - |
evil_random20_2.txt | WA | - |
evil_random20_3.txt | AC | 1,623 ms
183,652 KB |
ソースコード
n, m, q = map(int, input().split()) # import sys # input = sys.stdin.readline # mp = map(int, sys.stdin.read().split()) # ab = list(zip(mp,mp)) ab = [] for i in range(n): a,b = map(int, input().split()) ab.append((a,b)) katidp = [[0 for i in range(1 << n)] for i in range(2)] resdp = [[0 for i in range(1 << n)] for i in range(2)] resdp[0][0] = m resdp[1][0] = q que = set([0]) for j in range(n): nq = set() while que: state = que.pop() mkati = katidp[0][state] qkati = katidp[1][state] mres = resdp[0][state] qres = resdp[1][state] for k in range(n): if state & (1 << k): continue else: nstate = state | (1 << k) nq.add(nstate) kati = ab[k][1] val = ab[k][0] if mres < val: nres = mres nkati = mkati else: nkati = mkati + kati nres = mres - val if katidp[0][nstate] < nkati: katidp[0][nstate] = nkati resdp[0][nstate] = nres elif katidp[0][nstate] == nkati: if resdp[0][nstate] < nres: resdp[0][nstate] = nres if qres < val: nres = qres nkati = mkati else: nkati = mkati + kati nres = qres - val if katidp[1][nstate] < nkati: katidp[1][nstate] = nkati resdp[1][nstate] = nres elif katidp[1][nstate] == nkati: if resdp[1][nstate] < nres: resdp[1][nstate] = nres que = nq # print(katidp) mask = (1 << n) - 1 ans = 0 for i in range(1 << n): j = mask ^ i ans = max(ans, katidp[0][i] + katidp[1][j]) print(ans)