結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 25 ms
10,752 KB
testcase_03 AC 25 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 27 ms
10,880 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 26 ms
10,880 KB
testcase_08 WA -
testcase_09 AC 27 ms
10,752 KB
testcase_10 AC 25 ms
10,752 KB
testcase_11 AC 25 ms
10,752 KB
testcase_12 AC 25 ms
10,752 KB
testcase_13 WA -
testcase_14 AC 204 ms
11,392 KB
testcase_15 AC 216 ms
11,264 KB
testcase_16 AC 27 ms
10,752 KB
testcase_17 AC 88 ms
11,008 KB
testcase_18 AC 246 ms
11,520 KB
testcase_19 AC 242 ms
11,648 KB
testcase_20 AC 143 ms
11,136 KB
testcase_21 AC 115 ms
11,136 KB
testcase_22 WA -
testcase_23 AC 264 ms
11,648 KB
testcase_24 AC 554 ms
12,288 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