結果

問題 No.107 モンスター
ユーザー lloyzlloyz
提出日時 2023-11-14 07:26:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 509 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,228 KB
最終ジャッジ日時 2023-11-14 07:26:23
合計ジャッジ時間 2,759 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 AC 35 ms
53,460 KB
testcase_09 AC 35 ms
53,460 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 43 ms
53,460 KB
testcase_12 AC 35 ms
53,460 KB
testcase_13 AC 65 ms
72,712 KB
testcase_14 AC 69 ms
73,212 KB
testcase_15 AC 69 ms
73,212 KB
testcase_16 AC 36 ms
53,460 KB
testcase_17 AC 65 ms
70,672 KB
testcase_18 AC 61 ms
69,124 KB
testcase_19 AC 62 ms
69,124 KB
testcase_20 AC 68 ms
72,716 KB
testcase_21 AC 65 ms
72,728 KB
testcase_22 AC 75 ms
75,940 KB
testcase_23 AC 80 ms
76,180 KB
testcase_24 AC 78 ms
76,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
D = list(map(int, input().split()))

DP = [0 for _ in range(1 << n)]
DP[0] = 100
for bit in range(1 << n):
    if DP[bit] == 0:
        continue
    res = DP[bit]
    max_ = 100
    seen = set()
    for i in range(n):
        if (bit >> i) & 1:
            seen.add(i)
            if D[i] < 0:
                max_ += 100
    for i in range(n):
        if i in seen:
            continue
        nbit = bit | (1 << i)
        DP[nbit] = max(DP[nbit], min(max_, DP[bit] + D[i]))
print(DP[-1])
0