結果

問題 No.286 Modulo Discount Store
ユーザー brthyyjpbrthyyjp
提出日時 2021-09-28 01:04:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 76,680 KB
最終ジャッジ日時 2023-09-21 04:03:06
合計ジャッジ時間 6,050 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,956 KB
testcase_01 AC 86 ms
76,304 KB
testcase_02 AC 92 ms
76,380 KB
testcase_03 AC 76 ms
71,000 KB
testcase_04 AC 77 ms
70,972 KB
testcase_05 AC 76 ms
70,964 KB
testcase_06 AC 100 ms
76,268 KB
testcase_07 AC 75 ms
71,288 KB
testcase_08 AC 75 ms
71,100 KB
testcase_09 AC 78 ms
70,992 KB
testcase_10 AC 95 ms
76,304 KB
testcase_11 AC 77 ms
71,276 KB
testcase_12 AC 74 ms
71,252 KB
testcase_13 AC 97 ms
76,524 KB
testcase_14 AC 77 ms
71,140 KB
testcase_15 AC 77 ms
71,228 KB
testcase_16 AC 84 ms
76,364 KB
testcase_17 AC 107 ms
76,680 KB
testcase_18 AC 90 ms
76,248 KB
testcase_19 AC 77 ms
70,712 KB
testcase_20 AC 90 ms
76,360 KB
testcase_21 AC 75 ms
71,176 KB
testcase_22 AC 75 ms
71,240 KB
testcase_23 AC 96 ms
76,440 KB
testcase_24 AC 75 ms
71,232 KB
testcase_25 AC 90 ms
75,968 KB
testcase_26 AC 75 ms
71,232 KB
testcase_27 AC 91 ms
76,424 KB
testcase_28 AC 98 ms
75,984 KB
testcase_29 AC 78 ms
71,036 KB
testcase_30 AC 77 ms
70,956 KB
testcase_31 AC 90 ms
76,340 KB
testcase_32 AC 91 ms
76,372 KB
testcase_33 AC 76 ms
70,996 KB
testcase_34 AC 76 ms
70,968 KB
testcase_35 AC 85 ms
76,120 KB
testcase_36 AC 77 ms
71,032 KB
testcase_37 AC 93 ms
76,316 KB
testcase_38 AC 74 ms
71,064 KB
testcase_39 AC 97 ms
76,328 KB
testcase_40 AC 75 ms
71,204 KB
testcase_41 AC 79 ms
70,968 KB
testcase_42 AC 76 ms
71,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

INF = 10**18
dp = [INF]*(1<<n)
dp[0] = 0
for s in range(1<<n):
    d = 0
    for i in range(n):
        if (s>>i)&1:
            d += M[i]
    d %= 1000
    for i in range(n):
        if (s>>i)&1:
            continue
        ns = s|(1<<i)
        dp[ns] = min(dp[ns], dp[s]+max(0, M[i]-d))
print(dp[-1])
0