結果

問題 No.107 モンスター
ユーザー Poina15Poina15
提出日時 2018-08-25 01:44:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 249 ms / 5,000 ms
コード長 499 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 10,720 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-09-05 23:12:10
合計ジャッジ時間 3,144 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,780 KB
testcase_01 AC 15 ms
7,728 KB
testcase_02 AC 15 ms
7,916 KB
testcase_03 AC 15 ms
7,856 KB
testcase_04 AC 16 ms
7,944 KB
testcase_05 AC 16 ms
7,788 KB
testcase_06 AC 16 ms
7,936 KB
testcase_07 AC 15 ms
7,808 KB
testcase_08 AC 15 ms
7,896 KB
testcase_09 AC 16 ms
7,928 KB
testcase_10 AC 16 ms
7,800 KB
testcase_11 AC 16 ms
7,740 KB
testcase_12 AC 17 ms
7,920 KB
testcase_13 AC 110 ms
8,352 KB
testcase_14 AC 229 ms
8,456 KB
testcase_15 AC 226 ms
8,556 KB
testcase_16 AC 16 ms
7,828 KB
testcase_17 AC 44 ms
8,248 KB
testcase_18 AC 44 ms
8,552 KB
testcase_19 AC 44 ms
8,556 KB
testcase_20 AC 148 ms
8,292 KB
testcase_21 AC 103 ms
8,308 KB
testcase_22 AC 182 ms
8,220 KB
testcase_23 AC 249 ms
8,704 KB
testcase_24 AC 150 ms
8,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
D = list(map(int, input().split()))
# 残り体力
dp = [0] * (1 << N)
dp[0] = 100
for msk in range(1 << N):
    if dp[msk] <= 0:
        continue
    # 最大体力を計算
    limit = 100
    for j in range(N):
        if msk & 1 << j and D[j] < 0:
            # 悪いモンスターのとき
            limit += 100

    for i in range(N):
        if msk & 1 << i:
            continue
        dp[msk | 1 << i] = max(dp[msk | 1 << i], min(dp[msk] + D[i], limit))
print(dp[-1])
0