結果

問題 No.286 Modulo Discount Store
ユーザー mlihua09mlihua09
提出日時 2020-09-16 16:04:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 87,320 KB
実行使用メモリ 77,884 KB
最終ジャッジ日時 2023-09-04 03:37:29
合計ジャッジ時間 6,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,452 KB
testcase_01 AC 72 ms
71,620 KB
testcase_02 AC 109 ms
77,464 KB
testcase_03 AC 69 ms
71,472 KB
testcase_04 AC 71 ms
71,232 KB
testcase_05 AC 70 ms
71,412 KB
testcase_06 AC 111 ms
77,804 KB
testcase_07 AC 70 ms
71,108 KB
testcase_08 AC 69 ms
71,492 KB
testcase_09 AC 70 ms
71,376 KB
testcase_10 AC 98 ms
77,476 KB
testcase_11 AC 72 ms
71,568 KB
testcase_12 AC 69 ms
71,416 KB
testcase_13 AC 106 ms
77,732 KB
testcase_14 AC 70 ms
71,260 KB
testcase_15 AC 69 ms
71,112 KB
testcase_16 AC 72 ms
71,368 KB
testcase_17 AC 128 ms
77,884 KB
testcase_18 AC 97 ms
77,536 KB
testcase_19 AC 69 ms
71,356 KB
testcase_20 AC 87 ms
76,024 KB
testcase_21 AC 70 ms
71,364 KB
testcase_22 AC 70 ms
71,260 KB
testcase_23 AC 107 ms
77,468 KB
testcase_24 AC 69 ms
71,368 KB
testcase_25 AC 97 ms
77,300 KB
testcase_26 AC 71 ms
71,536 KB
testcase_27 AC 99 ms
77,432 KB
testcase_28 AC 114 ms
77,628 KB
testcase_29 AC 72 ms
71,580 KB
testcase_30 AC 69 ms
71,256 KB
testcase_31 AC 82 ms
76,320 KB
testcase_32 AC 82 ms
76,212 KB
testcase_33 AC 71 ms
71,412 KB
testcase_34 AC 71 ms
71,108 KB
testcase_35 AC 74 ms
71,104 KB
testcase_36 AC 71 ms
71,500 KB
testcase_37 AC 100 ms
77,316 KB
testcase_38 AC 72 ms
71,548 KB
testcase_39 AC 112 ms
77,424 KB
testcase_40 AC 71 ms
71,228 KB
testcase_41 AC 71 ms
71,420 KB
testcase_42 AC 71 ms
71,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


N = int(input())

M = [int(input()) for i in range(N)]

DP = [10 ** 9] * 2 ** N
X = [0] * 2 ** N

DP[0] = 0

from itertools import combinations

for i in range(1, N + 1):
    
    for C in combinations(range(N), r=i):
        
        x = sum([2 ** c for c in C])
        X[x] = X[x - 2 ** C[0]] + M[C[0]]
        
        DP[x] = min([DP[x - 2 ** c] + max(0, M[c] - X[x - 2 ** c] % 1000) for c in C])
print(DP[-1])
0