結果

問題 No.286 Modulo Discount Store
ユーザー 👑 rin204rin204
提出日時 2022-07-02 20:25:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 76,988 KB
最終ジャッジ日時 2023-08-18 12:32:53
合計ジャッジ時間 6,048 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,384 KB
testcase_01 AC 86 ms
76,904 KB
testcase_02 AC 89 ms
76,724 KB
testcase_03 AC 73 ms
71,408 KB
testcase_04 AC 73 ms
71,188 KB
testcase_05 AC 72 ms
71,576 KB
testcase_06 AC 92 ms
76,604 KB
testcase_07 AC 72 ms
71,344 KB
testcase_08 AC 73 ms
71,188 KB
testcase_09 AC 74 ms
71,384 KB
testcase_10 AC 88 ms
76,680 KB
testcase_11 AC 73 ms
71,312 KB
testcase_12 AC 72 ms
71,500 KB
testcase_13 AC 93 ms
76,752 KB
testcase_14 AC 73 ms
71,512 KB
testcase_15 AC 72 ms
71,420 KB
testcase_16 AC 79 ms
76,628 KB
testcase_17 AC 102 ms
76,988 KB
testcase_18 AC 86 ms
76,964 KB
testcase_19 AC 72 ms
71,328 KB
testcase_20 AC 87 ms
76,916 KB
testcase_21 AC 73 ms
71,192 KB
testcase_22 AC 73 ms
71,412 KB
testcase_23 AC 93 ms
76,744 KB
testcase_24 AC 72 ms
71,396 KB
testcase_25 AC 89 ms
76,688 KB
testcase_26 AC 73 ms
71,420 KB
testcase_27 AC 91 ms
76,768 KB
testcase_28 AC 95 ms
76,464 KB
testcase_29 AC 73 ms
71,428 KB
testcase_30 AC 73 ms
71,488 KB
testcase_31 AC 88 ms
76,752 KB
testcase_32 AC 85 ms
76,692 KB
testcase_33 AC 73 ms
71,492 KB
testcase_34 AC 73 ms
71,476 KB
testcase_35 AC 79 ms
76,540 KB
testcase_36 AC 73 ms
71,184 KB
testcase_37 AC 89 ms
76,768 KB
testcase_38 AC 74 ms
71,484 KB
testcase_39 AC 92 ms
76,748 KB
testcase_40 AC 72 ms
71,512 KB
testcase_41 AC 72 ms
71,396 KB
testcase_42 AC 72 ms
71,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
m = [int(input()) for _ in range(n)]
dp = [0] * (1 << n)
for bit in range(1 << n):
    tot = 0
    for i in range(n):
        if bit >> i & 1:
            tot += m[i]
    tot %= 1000
    for i in range(n):
        if not bit >> i & 1:
            plus = min(m[i], tot)
            nbit = bit | (1 << i)
            dp[nbit] = max(dp[nbit], dp[bit] + plus)
ans = sum(m) - dp[-1]
print(ans)
0