結果

問題 No.107 モンスター
ユーザー 👑 colognecologne
提出日時 2022-02-02 16:55:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,320 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2023-09-02 02:51:36
合計ジャッジ時間 3,746 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,288 KB
testcase_01 AC 69 ms
71,340 KB
testcase_02 AC 67 ms
71,240 KB
testcase_03 AC 68 ms
71,208 KB
testcase_04 AC 72 ms
71,240 KB
testcase_05 AC 68 ms
71,340 KB
testcase_06 AC 69 ms
71,340 KB
testcase_07 AC 68 ms
71,116 KB
testcase_08 AC 68 ms
71,432 KB
testcase_09 AC 68 ms
71,388 KB
testcase_10 AC 71 ms
71,268 KB
testcase_11 AC 70 ms
71,388 KB
testcase_12 AC 69 ms
71,204 KB
testcase_13 AC 88 ms
76,512 KB
testcase_14 AC 90 ms
76,772 KB
testcase_15 AC 89 ms
76,432 KB
testcase_16 AC 69 ms
71,096 KB
testcase_17 AC 92 ms
76,192 KB
testcase_18 AC 91 ms
76,840 KB
testcase_19 AC 91 ms
77,148 KB
testcase_20 AC 91 ms
76,464 KB
testcase_21 AC 94 ms
76,348 KB
testcase_22 AC 93 ms
76,464 KB
testcase_23 AC 97 ms
76,900 KB
testcase_24 AC 98 ms
77,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def input(): return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    *D, = map(int, input().split())

    DP = [0]*(1 << N)

    DP[0] = 100
    for i in range(0, 1 << N):
        if DP[i] == 0:
            continue

        mhp = 100
        for j in range(N):
            if D[j] < 0 and i & (1 << j):
                mhp += 100

        for j in range(N):
            if i & (1 << j) == 0:
                DP[i | (1 << j)] = max(
                    DP[i | (1 << j)], min(mhp, DP[i] + D[j]))

    print(DP[-1])


if __name__ == '__main__':
    main()
0