結果

問題 No.286 Modulo Discount Store
ユーザー rpy3cpprpy3cpp
提出日時 2015-10-09 22:59:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 10,920 KB
最終ジャッジ日時 2023-09-27 10:16:52
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,900 KB
testcase_01 AC 15 ms
7,804 KB
testcase_02 AC 90 ms
8,892 KB
testcase_03 AC 14 ms
7,800 KB
testcase_04 AC 15 ms
7,904 KB
testcase_05 AC 15 ms
7,860 KB
testcase_06 AC 180 ms
9,496 KB
testcase_07 AC 14 ms
7,872 KB
testcase_08 AC 14 ms
7,912 KB
testcase_09 AC 14 ms
7,804 KB
testcase_10 AC 53 ms
8,488 KB
testcase_11 AC 14 ms
7,860 KB
testcase_12 AC 14 ms
7,788 KB
testcase_13 AC 87 ms
8,788 KB
testcase_14 AC 15 ms
7,820 KB
testcase_15 AC 14 ms
7,904 KB
testcase_16 AC 15 ms
7,848 KB
testcase_17 AC 381 ms
10,920 KB
testcase_18 AC 50 ms
8,552 KB
testcase_19 AC 14 ms
7,924 KB
testcase_20 AC 21 ms
8,224 KB
testcase_21 AC 16 ms
7,804 KB
testcase_22 AC 15 ms
7,864 KB
testcase_23 AC 95 ms
8,848 KB
testcase_24 AC 16 ms
7,972 KB
testcase_25 AC 32 ms
8,496 KB
testcase_26 AC 14 ms
7,856 KB
testcase_27 AC 31 ms
8,436 KB
testcase_28 AC 181 ms
9,608 KB
testcase_29 AC 14 ms
7,912 KB
testcase_30 AC 14 ms
7,784 KB
testcase_31 AC 18 ms
7,800 KB
testcase_32 AC 18 ms
7,800 KB
testcase_33 AC 15 ms
7,904 KB
testcase_34 AC 15 ms
7,968 KB
testcase_35 AC 16 ms
7,852 KB
testcase_36 AC 14 ms
7,788 KB
testcase_37 AC 33 ms
8,316 KB
testcase_38 AC 15 ms
7,824 KB
testcase_39 AC 181 ms
9,604 KB
testcase_40 AC 14 ms
7,928 KB
testcase_41 AC 14 ms
7,852 KB
testcase_42 AC 15 ms
7,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Ms = [int(input()) for i in range(N)]
dp = [float('inf')] * (1 << N)
dp[0] = 0
discount = [0] * (1 << N)
full = (1 << N) - 1
for m in range(N):
    msb = 1 << m
    for mask in range(1 << m):
        discount[msb + mask] = (discount[mask] + Ms[m]) % 1000
frontiers = [0]
for m in range(N):
    new_frontiers = []
    for f in frontiers:
        dpf = dp[f]
        dsc = discount[f]
        for idx in range(N):
            bit = 1 << idx
            if bit & f:
                continue
            nf = bit | f
            if dp[nf] == float('inf'):
                new_frontiers.append(nf)
            dp[nf] = min(dp[nf], dpf + max(0, Ms[idx] - dsc))
    frontiers = new_frontiers
print(dp[full])
0