結果

問題 No.107 モンスター
ユーザー Nikkuniku029Nikkuniku029
提出日時 2021-08-22 17:51:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-04-24 08:33:44
合計ジャッジ時間 4,298 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 WA -
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 30 ms
10,880 KB
testcase_12 AC 31 ms
10,752 KB
testcase_13 WA -
testcase_14 AC 233 ms
11,264 KB
testcase_15 AC 233 ms
11,264 KB
testcase_16 AC 31 ms
10,880 KB
testcase_17 AC 97 ms
11,008 KB
testcase_18 AC 269 ms
11,648 KB
testcase_19 AC 264 ms
11,648 KB
testcase_20 AC 159 ms
11,264 KB
testcase_21 AC 126 ms
11,008 KB
testcase_22 WA -
testcase_23 AC 290 ms
11,648 KB
testcase_24 AC 607 ms
12,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for s in range(1 << n):
    if dp[s] <= 0:
        continue
    limit = 1
    for j in range(n):
        if (s >> j) & 1:
            limit += 1

    for v in range(n):
        # まだ戦っていない
        if (s >> v) & 1 == 0:
            # 正の値の時
            if d[v] >= 0:
                dp[s | (1 << v)] = min(
                    max(dp[s | (1 << v)], dp[s]+d[v]), limit*100)
            # 負の値の時
            elif dp[s]+d[v] > 0:
                dp[s | (1 << v)] = max(dp[s | (1 << v)], dp[s]+d[v])

ans = max(0, dp[(1 << n)-1])
print(ans)
0