結果
問題 | No.2686 商品券の使い道 |
ユーザー | Yakumo221 |
提出日時 | 2024-03-20 23:32:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,855 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 192,932 KB |
最終ジャッジ日時 | 2024-09-30 09:35:07 |
合計ジャッジ時間 | 58,695 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 41 ms
51,968 KB |
testcase_02 | AC | 523 ms
104,536 KB |
testcase_03 | AC | 516 ms
106,684 KB |
testcase_04 | WA | - |
testcase_05 | AC | 504 ms
114,900 KB |
testcase_06 | AC | 526 ms
105,332 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 500 ms
109,176 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 458 ms
105,172 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 436 ms
104,908 KB |
testcase_21 | AC | 510 ms
110,784 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 509 ms
113,640 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 1,802 ms
187,812 KB |
testcase_31 | WA | - |
testcase_32 | AC | 1,795 ms
173,820 KB |
testcase_33 | AC | 1,746 ms
188,036 KB |
testcase_34 | WA | - |
testcase_35 | AC | 2,008 ms
185,088 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 1,929 ms
178,056 KB |
testcase_39 | AC | 2,065 ms
167,412 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 | 2,017 ms
183,524 KB |
ソースコード
n,m,q=map(int,input().split()) 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)