結果

問題 No.286 Modulo Discount Store
ユーザー rlangevinrlangevin
提出日時 2023-01-08 20:07:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 533 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 333,720 KB
最終ジャッジ日時 2023-08-22 05:18:33
合計ジャッジ時間 10,053 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
76,416 KB
testcase_01 AC 104 ms
79,304 KB
testcase_02 AC 666 ms
141,080 KB
testcase_03 AC 79 ms
76,572 KB
testcase_04 AC 84 ms
77,512 KB
testcase_05 AC 72 ms
75,960 KB
testcase_06 AC 1,312 ms
205,512 KB
testcase_07 AC 64 ms
74,816 KB
testcase_08 AC 81 ms
75,852 KB
testcase_09 AC 79 ms
75,824 KB
testcase_10 AC 359 ms
109,120 KB
testcase_11 AC 77 ms
76,624 KB
testcase_12 AC 80 ms
76,468 KB
testcase_13 AC 722 ms
141,196 KB
testcase_14 AC 83 ms
76,228 KB
testcase_15 AC 72 ms
76,240 KB
testcase_16 AC 99 ms
79,332 KB
testcase_17 TLE -
testcase_18 AC 432 ms
109,524 KB
testcase_19 AC 72 ms
76,296 KB
testcase_20 AC 161 ms
85,668 KB
testcase_21 AC 76 ms
76,560 KB
testcase_22 AC 82 ms
76,556 KB
testcase_23 AC 715 ms
141,984 KB
testcase_24 AC 79 ms
76,604 KB
testcase_25 AC 235 ms
93,984 KB
testcase_26 AC 76 ms
76,216 KB
testcase_27 AC 216 ms
93,768 KB
testcase_28 AC 1,348 ms
205,676 KB
testcase_29 AC 75 ms
76,244 KB
testcase_30 AC 72 ms
76,300 KB
testcase_31 AC 121 ms
81,572 KB
testcase_32 AC 111 ms
80,880 KB
testcase_33 AC 82 ms
76,684 KB
testcase_34 AC 78 ms
76,500 KB
testcase_35 AC 92 ms
78,892 KB
testcase_36 AC 66 ms
75,004 KB
testcase_37 AC 221 ms
93,424 KB
testcase_38 AC 75 ms
76,460 KB
testcase_39 AC 1,344 ms
205,488 KB
testcase_40 AC 82 ms
76,492 KB
testcase_41 AC 86 ms
76,416 KB
testcase_42 AC 91 ms
76,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(s, m):
    return s * 1000 + m

N = int(input())
M = [0] * N
for i in range(N):
    M[i] = int(input())
    
inf = 10 ** 18
dp = [inf] * ((1 << N) * 1000)
dp[0] = 0
for s in range(1 << N):
    for i in range(N):
        if (s >> i)&1:
            continue
        ns = s | (1 << i)
        for m in range(1000):
            v = max(0, M[i] - m)
            nm = (m + M[i])%1000
            dp[f(ns, nm)] = min(dp[f(ns, nm)], dp[f(s, m)] + v)
ans = inf
for i in range(1000):
    ans = min(ans, dp[f((1 << N) - 1, i)])
print(ans)
0