結果

問題 No.286 Modulo Discount Store
ユーザー gahougahou
提出日時 2016-11-15 13:56:45
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,123 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 6,704 KB
実行使用メモリ 6,700 KB
最終ジャッジ日時 2023-08-17 06:57:46
合計ジャッジ時間 5,680 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,896 KB
testcase_01 AC 15 ms
5,964 KB
testcase_02 AC 224 ms
6,160 KB
testcase_03 AC 11 ms
5,984 KB
testcase_04 AC 12 ms
6,088 KB
testcase_05 AC 11 ms
5,848 KB
testcase_06 AC 494 ms
6,312 KB
testcase_07 AC 11 ms
6,128 KB
testcase_08 AC 11 ms
5,852 KB
testcase_09 AC 12 ms
6,064 KB
testcase_10 AC 100 ms
5,952 KB
testcase_11 AC 11 ms
5,944 KB
testcase_12 AC 12 ms
5,896 KB
testcase_13 AC 221 ms
6,124 KB
testcase_14 AC 11 ms
6,132 KB
testcase_15 AC 12 ms
5,920 KB
testcase_16 AC 13 ms
5,848 KB
testcase_17 AC 1,123 ms
6,700 KB
testcase_18 AC 101 ms
6,032 KB
testcase_19 AC 11 ms
5,896 KB
testcase_20 AC 27 ms
5,900 KB
testcase_21 AC 11 ms
5,956 KB
testcase_22 AC 11 ms
5,844 KB
testcase_23 AC 219 ms
6,080 KB
testcase_24 AC 11 ms
6,064 KB
testcase_25 AC 50 ms
6,028 KB
testcase_26 AC 11 ms
6,084 KB
testcase_27 AC 49 ms
5,984 KB
testcase_28 AC 493 ms
6,320 KB
testcase_29 AC 11 ms
5,928 KB
testcase_30 AC 11 ms
5,892 KB
testcase_31 AC 18 ms
5,992 KB
testcase_32 AC 18 ms
5,928 KB
testcase_33 AC 11 ms
5,860 KB
testcase_34 AC 11 ms
5,980 KB
testcase_35 AC 14 ms
5,992 KB
testcase_36 AC 11 ms
5,896 KB
testcase_37 AC 49 ms
5,968 KB
testcase_38 AC 12 ms
5,956 KB
testcase_39 AC 497 ms
6,360 KB
testcase_40 AC 11 ms
5,988 KB
testcase_41 AC 11 ms
5,844 KB
testcase_42 AC 11 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def minBuy(M,dp,st):
  minSum=10**9
  i=0
  while True:
    if st&2**i!=0:
      k=0
      tmpSum=0
      while True:
        if st<2**k: break
        if i==k:
          k+=1
          continue
        if st&2**k!=0:
          tmpSum+=M[k]
        k+=1
      minSum=min(minSum,dp[st-2**i]+max(0,M[i]-tmpSum%1000))
    i+=1
    if st<2**i: break
  return minSum

N=int(raw_input())
M=[]
for _ in xrange(N):
  M.append(int(raw_input()))
dp=[10**9]*(2**N)
dp[0]=0
for i in xrange(1,2**N):
  dp[i] = minBuy(M,dp,i)
print dp[2**N-1]
0