結果

問題 No.286 Modulo Discount Store
ユーザー nebukuro09nebukuro09
提出日時 2016-10-12 16:00:14
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 659 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 76,544 KB
実行使用メモリ 134,480 KB
最終ジャッジ日時 2024-05-01 20:23:15
合計ジャッジ時間 7,830 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
75,392 KB
testcase_01 AC 217 ms
78,208 KB
testcase_02 AC 214 ms
87,372 KB
testcase_03 AC 90 ms
76,672 KB
testcase_04 AC 95 ms
78,208 KB
testcase_05 AC 87 ms
75,392 KB
testcase_06 AC 343 ms
96,840 KB
testcase_07 AC 85 ms
75,520 KB
testcase_08 AC 86 ms
75,264 KB
testcase_09 AC 85 ms
75,648 KB
testcase_10 AC 147 ms
82,688 KB
testcase_11 AC 88 ms
76,544 KB
testcase_12 AC 86 ms
76,160 KB
testcase_13 AC 232 ms
87,148 KB
testcase_14 AC 84 ms
75,520 KB
testcase_15 AC 84 ms
75,520 KB
testcase_16 AC 105 ms
78,336 KB
testcase_17 AC 659 ms
134,480 KB
testcase_18 AC 143 ms
82,304 KB
testcase_19 AC 85 ms
75,648 KB
testcase_20 AC 129 ms
78,208 KB
testcase_21 AC 86 ms
75,136 KB
testcase_22 AC 85 ms
75,392 KB
testcase_23 AC 245 ms
86,884 KB
testcase_24 AC 85 ms
75,392 KB
testcase_25 AC 153 ms
80,384 KB
testcase_26 AC 86 ms
75,392 KB
testcase_27 AC 151 ms
80,128 KB
testcase_28 AC 359 ms
96,880 KB
testcase_29 AC 90 ms
75,392 KB
testcase_30 AC 87 ms
75,392 KB
testcase_31 AC 127 ms
78,336 KB
testcase_32 AC 120 ms
78,208 KB
testcase_33 AC 89 ms
75,520 KB
testcase_34 AC 92 ms
75,392 KB
testcase_35 AC 114 ms
78,336 KB
testcase_36 AC 86 ms
75,520 KB
testcase_37 AC 157 ms
80,336 KB
testcase_38 AC 85 ms
75,520 KB
testcase_39 AC 358 ms
96,780 KB
testcase_40 AC 85 ms
75,264 KB
testcase_41 AC 85 ms
75,520 KB
testcase_42 AC 86 ms
75,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
M = [int(raw_input()) for _ in xrange(N)]

mem = {}
def rec(p, b, acm):
    if b == ((1 << N) - 1):
        return 0
    if (p, b) in mem:
        return mem[(p, b)]
    m = float('inf')
    for i in xrange(N):
        if (1 << i) & b:
            continue
        price = max(0, M[i]-(acm%1000))
        m = min(m, rec(i, b+(1<<i), acm+M[i])+price)
    mem[(p, b)] = m
    return mem[(p, b)]
            
print min(rec(i, 1<<i, M[i])+M[i] for i in xrange(N))
0