結果

問題 No.107 モンスター
ユーザー rlangevinrlangevin
提出日時 2023-10-17 08:55:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 432 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 81,492 KB
実行使用メモリ 72,884 KB
最終ジャッジ日時 2023-10-17 08:55:57
合計ジャッジ時間 2,734 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,252 KB
testcase_01 AC 37 ms
53,252 KB
testcase_02 AC 37 ms
53,252 KB
testcase_03 AC 36 ms
53,252 KB
testcase_04 AC 37 ms
53,252 KB
testcase_05 AC 37 ms
53,252 KB
testcase_06 AC 37 ms
53,252 KB
testcase_07 AC 37 ms
53,252 KB
testcase_08 AC 37 ms
53,252 KB
testcase_09 AC 40 ms
53,252 KB
testcase_10 AC 38 ms
53,252 KB
testcase_11 AC 37 ms
53,252 KB
testcase_12 AC 38 ms
53,252 KB
testcase_13 AC 63 ms
66,136 KB
testcase_14 AC 66 ms
68,464 KB
testcase_15 AC 66 ms
68,464 KB
testcase_16 AC 37 ms
53,252 KB
testcase_17 AC 67 ms
70,284 KB
testcase_18 AC 62 ms
68,732 KB
testcase_19 AC 62 ms
68,724 KB
testcase_20 AC 66 ms
70,260 KB
testcase_21 AC 68 ms
70,284 KB
testcase_22 AC 72 ms
72,592 KB
testcase_23 AC 72 ms
70,776 KB
testcase_24 AC 75 ms
72,884 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] = min(ma + 100 * int(D[i] < 0), max(dp[nex], dp[s] + D[i]))

print(dp[-1])
0