結果

問題 No.107 モンスター
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-13 16:41:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 544 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 72,940 KB
最終ジャッジ日時 2023-10-19 03:41:17
合計ジャッジ時間 2,513 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,344 KB
testcase_01 AC 40 ms
53,344 KB
testcase_02 AC 40 ms
53,344 KB
testcase_03 AC 40 ms
53,344 KB
testcase_04 AC 39 ms
53,344 KB
testcase_05 AC 38 ms
53,344 KB
testcase_06 AC 39 ms
53,344 KB
testcase_07 AC 39 ms
53,344 KB
testcase_08 AC 43 ms
53,344 KB
testcase_09 AC 39 ms
53,344 KB
testcase_10 AC 39 ms
53,344 KB
testcase_11 AC 39 ms
53,344 KB
testcase_12 AC 40 ms
53,344 KB
testcase_13 AC 66 ms
68,248 KB
testcase_14 AC 68 ms
68,512 KB
testcase_15 AC 68 ms
68,512 KB
testcase_16 AC 40 ms
53,344 KB
testcase_17 AC 70 ms
70,336 KB
testcase_18 AC 66 ms
68,792 KB
testcase_19 AC 66 ms
68,796 KB
testcase_20 AC 69 ms
68,264 KB
testcase_21 AC 73 ms
70,348 KB
testcase_22 AC 77 ms
72,668 KB
testcase_23 AC 75 ms
70,828 KB
testcase_24 AC 78 ms
72,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for i in range(1<<n):
    if dp[i] < 0:
        continue

    num = 0
    for j in range(n):
        if i >> j & 1 and D[j] < 0:
            num += 1
    for j in range(n):
        if i >> j & 1:
            continue
        d = D[j]
        
        if d < 0:
            if d+dp[i] > 0:
                dp[i|1<<j] = max(dp[i|1<<j],dp[i]+d)
        else:
            hp = min(dp[i]+d,100*(num+1))
            dp[i|1<<j] = max(dp[i|1<<j],hp)
print(max(dp[-1],0))
0