結果

問題 No.286 Modulo Discount Store
ユーザー Tawara
提出日時 2015-10-13 21:45:24
言語 Python2
(2.7.18)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 10,044 KB
最終ジャッジ日時 2024-07-21 07:34:02
合計ジャッジ時間 2,265 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000
N = input()
M = [input() for i in xrange(N)]
dp = {0:(0,0)}
for i in xrange(N):
	tmp_dp = dict()
	for k,(t,v) in dp.iteritems():
		for j in xrange(N):
			jbit = 1 << j
			if (jbit & k) != 0:
				continue
			nk = k|jbit
			nv = v + max(0,M[j] - (t%mod))
			if not(nk in tmp_dp and nv >= tmp_dp[nk][1]):
				tmp_dp[nk] = (t+M[j],nv)
	dp = tmp_dp
print dp[2**N-1][1]
0