結果

問題 No.286 Modulo Discount Store
ユーザー ynyn
提出日時 2016-09-03 01:28:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 638 bytes
コンパイル時間 1,363 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 76,844 KB
最終ジャッジ日時 2023-08-09 20:35:35
合計ジャッジ時間 6,294 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,476 KB
testcase_01 AC 118 ms
76,384 KB
testcase_02 AC 92 ms
76,316 KB
testcase_03 AC 72 ms
71,308 KB
testcase_04 AC 73 ms
71,284 KB
testcase_05 AC 71 ms
71,300 KB
testcase_06 AC 97 ms
76,476 KB
testcase_07 AC 71 ms
71,480 KB
testcase_08 AC 71 ms
71,296 KB
testcase_09 AC 72 ms
71,336 KB
testcase_10 AC 89 ms
76,384 KB
testcase_11 AC 71 ms
71,236 KB
testcase_12 AC 76 ms
71,408 KB
testcase_13 AC 93 ms
76,688 KB
testcase_14 AC 75 ms
71,384 KB
testcase_15 AC 72 ms
71,584 KB
testcase_16 AC 80 ms
76,464 KB
testcase_17 AC 106 ms
76,844 KB
testcase_18 AC 87 ms
76,796 KB
testcase_19 AC 72 ms
71,172 KB
testcase_20 AC 85 ms
76,756 KB
testcase_21 AC 71 ms
71,284 KB
testcase_22 AC 72 ms
71,404 KB
testcase_23 AC 90 ms
76,536 KB
testcase_24 AC 70 ms
71,296 KB
testcase_25 AC 91 ms
76,604 KB
testcase_26 AC 72 ms
71,316 KB
testcase_27 AC 88 ms
76,372 KB
testcase_28 AC 93 ms
76,644 KB
testcase_29 AC 72 ms
71,296 KB
testcase_30 AC 72 ms
71,508 KB
testcase_31 AC 85 ms
76,252 KB
testcase_32 AC 83 ms
76,320 KB
testcase_33 AC 71 ms
71,240 KB
testcase_34 AC 72 ms
71,480 KB
testcase_35 AC 82 ms
76,400 KB
testcase_36 AC 74 ms
71,464 KB
testcase_37 AC 87 ms
76,736 KB
testcase_38 AC 73 ms
71,480 KB
testcase_39 AC 96 ms
76,748 KB
testcase_40 AC 74 ms
71,136 KB
testcase_41 AC 72 ms
71,400 KB
testcase_42 AC 74 ms
71,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [[10**10] * 2 for i in range(1 << n)]
for i in range(1 << n):
    dp[i][0] = 0

#購入済み商品の集合を表す
for i in range(1 << n):
    for j in range(n):
        #商品jが購入済み
        if (i >> j) % 2 == 1:
            continue

        #商品jが未購入
        if dp[i][0] == 0:
            dp[i | (1 << j)][0] = m[j]
            dp[i | (1 << j)][1] = m[j]
        else:
            dp[i | (1 << j)][0] = dp[i][0] + m[j]
            dp[i | (1 << j)][1] = min(dp[i | (1 << j)][1], dp[i][1] + max(0, m[j] - (dp[i][0] % 1000)))

print(dp[(1 << n) - 1][1])
0