結果

問題 No.286 Modulo Discount Store
ユーザー TawaraTawara
提出日時 2015-10-14 01:25:53
言語 Python2
(2.7.18)
結果
AC  
実行時間 552 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 6,700 KB
実行使用メモリ 11,668 KB
最終ジャッジ日時 2023-09-28 13:02:15
合計ジャッジ時間 4,143 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,032 KB
testcase_01 AC 13 ms
6,052 KB
testcase_02 AC 124 ms
7,404 KB
testcase_03 AC 12 ms
5,960 KB
testcase_04 AC 12 ms
5,972 KB
testcase_05 AC 11 ms
6,048 KB
testcase_06 AC 258 ms
7,956 KB
testcase_07 AC 11 ms
6,000 KB
testcase_08 AC 11 ms
5,996 KB
testcase_09 AC 12 ms
5,952 KB
testcase_10 AC 63 ms
6,372 KB
testcase_11 AC 12 ms
6,032 KB
testcase_12 AC 11 ms
5,968 KB
testcase_13 AC 125 ms
7,424 KB
testcase_14 AC 11 ms
6,048 KB
testcase_15 AC 11 ms
5,960 KB
testcase_16 AC 13 ms
6,068 KB
testcase_17 AC 552 ms
11,668 KB
testcase_18 AC 63 ms
6,372 KB
testcase_19 AC 11 ms
5,972 KB
testcase_20 AC 21 ms
6,100 KB
testcase_21 AC 11 ms
5,980 KB
testcase_22 AC 11 ms
6,052 KB
testcase_23 AC 125 ms
7,408 KB
testcase_24 AC 12 ms
6,200 KB
testcase_25 AC 35 ms
6,280 KB
testcase_26 AC 11 ms
6,208 KB
testcase_27 AC 34 ms
6,304 KB
testcase_28 AC 258 ms
8,096 KB
testcase_29 AC 12 ms
5,972 KB
testcase_30 AC 11 ms
5,960 KB
testcase_31 AC 15 ms
6,112 KB
testcase_32 AC 16 ms
6,072 KB
testcase_33 AC 11 ms
6,044 KB
testcase_34 AC 11 ms
6,092 KB
testcase_35 AC 12 ms
6,172 KB
testcase_36 AC 11 ms
5,960 KB
testcase_37 AC 34 ms
6,284 KB
testcase_38 AC 12 ms
6,064 KB
testcase_39 AC 259 ms
7,984 KB
testcase_40 AC 11 ms
6,048 KB
testcase_41 AC 11 ms
6,220 KB
testcase_42 AC 11 ms
6,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
M = [input() for i in xrange(N)]
ALL = 2**N - 1
dp = [150001]*(ALL+1)
total = {1<<i:M[i] for i in xrange(N)}
for i in xrange(N):
	dp[1<<i] = M[i]
for i in xrange(1,N):
	for j in xrange(ALL):
		if bin(j).count("1") == i:
			for k in xrange(N):
				bit = 1<<k
				if (j & bit) == 0:
					nxt = j|bit
					total[nxt] = total[j] + M[k]
					dp[nxt] = min(dp[nxt],dp[j]+max(0,M[k]-total[j]%1000))
print dp[ALL]
0