結果

問題 No.107 モンスター
ユーザー gahougahou
提出日時 2016-11-15 13:09:18
言語 Python2
(2.7.18)
結果
AC  
実行時間 537 ms / 5,000 ms
コード長 613 bytes
コンパイル時間 888 ms
コンパイル使用メモリ 6,696 KB
実行使用メモリ 6,520 KB
最終ジャッジ日時 2023-08-23 06:55:31
合計ジャッジ時間 4,694 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,868 KB
testcase_01 AC 11 ms
6,092 KB
testcase_02 AC 11 ms
5,888 KB
testcase_03 AC 11 ms
6,000 KB
testcase_04 AC 11 ms
5,924 KB
testcase_05 AC 11 ms
5,852 KB
testcase_06 AC 11 ms
6,096 KB
testcase_07 AC 11 ms
6,096 KB
testcase_08 AC 12 ms
5,924 KB
testcase_09 AC 11 ms
5,872 KB
testcase_10 AC 11 ms
5,944 KB
testcase_11 AC 11 ms
6,096 KB
testcase_12 AC 12 ms
5,892 KB
testcase_13 AC 137 ms
5,912 KB
testcase_14 AC 286 ms
6,384 KB
testcase_15 AC 285 ms
6,180 KB
testcase_16 AC 11 ms
5,888 KB
testcase_17 AC 66 ms
5,952 KB
testcase_18 AC 480 ms
6,320 KB
testcase_19 AC 476 ms
6,208 KB
testcase_20 AC 149 ms
6,056 KB
testcase_21 AC 138 ms
5,960 KB
testcase_22 AC 272 ms
6,036 KB
testcase_23 AC 537 ms
6,520 KB
testcase_24 AC 509 ms
6,356 KB
権限があれば一括ダウンロードができます

ソースコード

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