結果

問題 No.286 Modulo Discount Store
ユーザー tjaketjake
提出日時 2015-12-03 23:38:39
言語 Python2
(2.7.18)
結果
AC  
実行時間 400 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 6,660 KB
実行使用メモリ 10,136 KB
最終ジャッジ日時 2023-10-12 09:36:53
合計ジャッジ時間 3,384 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,248 KB
testcase_01 AC 13 ms
6,228 KB
testcase_02 AC 95 ms
7,064 KB
testcase_03 AC 12 ms
6,368 KB
testcase_04 AC 13 ms
6,284 KB
testcase_05 AC 12 ms
6,272 KB
testcase_06 AC 189 ms
8,124 KB
testcase_07 AC 12 ms
6,308 KB
testcase_08 AC 12 ms
6,324 KB
testcase_09 AC 12 ms
6,324 KB
testcase_10 AC 50 ms
6,640 KB
testcase_11 AC 12 ms
6,416 KB
testcase_12 AC 13 ms
6,276 KB
testcase_13 AC 96 ms
7,116 KB
testcase_14 AC 12 ms
6,448 KB
testcase_15 AC 12 ms
6,408 KB
testcase_16 AC 14 ms
6,256 KB
testcase_17 AC 400 ms
10,136 KB
testcase_18 AC 51 ms
6,700 KB
testcase_19 AC 12 ms
6,408 KB
testcase_20 AC 21 ms
6,340 KB
testcase_21 AC 13 ms
6,296 KB
testcase_22 AC 12 ms
6,276 KB
testcase_23 AC 93 ms
7,196 KB
testcase_24 AC 13 ms
6,356 KB
testcase_25 AC 30 ms
6,364 KB
testcase_26 AC 12 ms
6,364 KB
testcase_27 AC 28 ms
6,568 KB
testcase_28 AC 184 ms
8,132 KB
testcase_29 AC 12 ms
6,280 KB
testcase_30 AC 12 ms
6,296 KB
testcase_31 AC 16 ms
6,328 KB
testcase_32 AC 15 ms
6,368 KB
testcase_33 AC 12 ms
6,248 KB
testcase_34 AC 12 ms
6,196 KB
testcase_35 AC 14 ms
6,220 KB
testcase_36 AC 12 ms
6,432 KB
testcase_37 AC 29 ms
6,528 KB
testcase_38 AC 12 ms
6,444 KB
testcase_39 AC 192 ms
8,288 KB
testcase_40 AC 12 ms
6,232 KB
testcase_41 AC 12 ms
6,276 KB
testcase_42 AC 13 ms
6,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
n = input()
m = [input() for i in xrange(n)]

dist = [10**7]*(1<<n)

que = [(0, 0, 0)]
while len(que):
    co, su, state = heappop(que)
    if dist[state] < co: continue
    for i in xrange(n):
        v = 1<<i
        if not state&v:
            n_co = co + max(0, m[i] - (su%1000))
            n_st = state|v
            if n_co < dist[n_st]:
                dist[n_st] = n_co
                heappush(que, (n_co, su+m[i], n_st))
print dist[(1<<n)-1]
0