結果

問題 No.107 モンスター
ユーザー roarisroaris
提出日時 2019-12-04 12:32:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 556 bytes
コンパイル時間 556 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 78,484 KB
最終ジャッジ日時 2023-08-20 05:16:36
合計ジャッジ時間 4,367 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,924 KB
testcase_01 AC 70 ms
70,968 KB
testcase_02 AC 71 ms
71,316 KB
testcase_03 AC 71 ms
71,088 KB
testcase_04 AC 72 ms
71,100 KB
testcase_05 AC 71 ms
71,336 KB
testcase_06 AC 70 ms
71,132 KB
testcase_07 AC 71 ms
71,016 KB
testcase_08 AC 71 ms
71,412 KB
testcase_09 AC 73 ms
71,120 KB
testcase_10 AC 73 ms
70,988 KB
testcase_11 AC 71 ms
71,120 KB
testcase_12 AC 72 ms
71,208 KB
testcase_13 AC 114 ms
76,556 KB
testcase_14 AC 114 ms
77,496 KB
testcase_15 AC 111 ms
77,696 KB
testcase_16 AC 73 ms
70,980 KB
testcase_17 AC 115 ms
77,380 KB
testcase_18 AC 138 ms
77,984 KB
testcase_19 AC 133 ms
78,040 KB
testcase_20 AC 105 ms
76,580 KB
testcase_21 AC 116 ms
77,416 KB
testcase_22 AC 133 ms
77,852 KB
testcase_23 AC 137 ms
78,196 KB
testcase_24 AC 148 ms
78,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
D = list(map(int, input().split()))
dp = [-float('inf')]*(1<<N)
dp[0] = 100

for i in range(1<<N):
    max_hp = 100
    
    for j in range(N):
        if (i>>j)&1 and D[j]<0:
            max_hp += 100
            
    for j in range(N):
        if not (i>>j)&1:
            if D[j]>0:
                dp[i|(1<<j)] = max(dp[i|(1<<j)], min(dp[i]+D[j], max_hp))
            else:
                if dp[i]+D[j]>0:
                    dp[i|(1<<j)] = max(dp[i|(1<<j)], dp[i]+D[j])

if dp[-1]==-float('inf'):
    print(0)
else:
    print(dp[-1])
0