結果
| 問題 |
No.107 モンスター
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-05 15:29:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 90 ms / 5,000 ms |
| コード長 | 702 bytes |
| コンパイル時間 | 523 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 69,104 KB |
| 最終ジャッジ日時 | 2024-10-14 01:16:30 |
| 合計ジャッジ時間 | 2,838 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# %%
N, *D = map(int, read().split())
# %%
HP_limit = [100]
for x in D:
if x > 0:
HP_limit += HP_limit
else:
HP_limit += [y + 100 for y in HP_limit]
# %%
dp = [0] * (1 << N)
dp[0] = 100
for n in range(1 << N):
for i, d in enumerate(D):
if n & (1 << i):
continue
if not dp[n]:
continue
m = n ^ (1 << i)
if d > 0:
x = min(dp[n] + d, HP_limit[n])
else:
x = dp[n] + d
if dp[m] < x:
dp[m] = x
# %%
print(max(0, dp[-1]))
maspy