結果

問題 No.107 モンスター
ユーザー gahou
提出日時 2016-11-15 13:09:18
言語 Python2
(2.7.18)
結果
AC  
実行時間 566 ms / 5,000 ms
コード長 613 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 7,076 KB
実行使用メモリ 7,040 KB
最終ジャッジ日時 2024-12-21 07:22:50
合計ジャッジ時間 4,884 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

def maxLife(D,_st):
  st=_st
  c=0
  i=0
  while True:
    if st%2==1 and D[i]<0:
      c+=1
    i+=1
    st=(st-st%2)/2
    if st==0: break
  return (c+1)*100

def calcLife(D,dp,_st):
  st=_st
  i=0
  tmpMax=0
  limitLife=maxLife(D,_st)
  while True:
    if st%2==1 and dp[_st-2**i]>0:
      life=min(dp[_st-2**i]+D[i],limitLife)
      tmpMax=max(tmpMax,life)
    i+=1
    st=(st-st%2)/2
    if st==0: break
  return tmpMax

N=int(raw_input())
D=map(int,raw_input().split())
# dp[i] : max life for beat status(i) monsters
dp=[0]*(2**N)
dp[0]=100
for i in xrange(1,2**N):
  dp[i]=calcLife(D,dp,i)
print dp[2**N-1]
0