結果

問題 No.107 モンスター
ユーザー rlangevinrlangevin
提出日時 2023-10-17 19:41:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 410 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 71,040 KB
最終ジャッジ日時 2023-10-17 19:41:57
合計ジャッジ時間 2,730 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,488 KB
testcase_01 AC 37 ms
53,488 KB
testcase_02 AC 37 ms
53,488 KB
testcase_03 AC 37 ms
53,488 KB
testcase_04 AC 36 ms
53,488 KB
testcase_05 AC 36 ms
53,488 KB
testcase_06 AC 37 ms
53,488 KB
testcase_07 AC 37 ms
53,488 KB
testcase_08 AC 37 ms
53,488 KB
testcase_09 AC 37 ms
53,488 KB
testcase_10 AC 37 ms
53,488 KB
testcase_11 AC 37 ms
53,488 KB
testcase_12 AC 37 ms
53,488 KB
testcase_13 AC 61 ms
66,360 KB
testcase_14 AC 60 ms
66,624 KB
testcase_15 AC 61 ms
66,624 KB
testcase_16 AC 37 ms
53,488 KB
testcase_17 AC 60 ms
68,436 KB
testcase_18 AC 59 ms
66,896 KB
testcase_19 AC 59 ms
66,896 KB
testcase_20 AC 60 ms
68,408 KB
testcase_21 AC 59 ms
68,424 KB
testcase_22 AC 64 ms
68,684 KB
testcase_23 AC 65 ms
68,936 KB
testcase_24 AC 68 ms
71,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

N2 = 1 << N
dp = [0] * N2
dp[0] = 100
for s in range(N2):
    if dp[s] == 0:
        continue
    ma = 100
    for i in range(N):
        if ((s >> i) & 1) and D[i] < 0:
            ma += 100
    for i in range(N):
        if (s >> i) & 1:
            continue
        nex = s | (1 << i)
        dp[nex] = max(dp[nex], min(ma, dp[s] + D[i]))

print(dp[-1])
0