結果
| 問題 |
No.107 モンスター
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-21 15:08:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 5,000 ms |
| コード長 | 1,140 bytes |
| コンパイル時間 | 640 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 75,264 KB |
| 最終ジャッジ日時 | 2024-10-15 06:06:53 |
| 合計ジャッジ時間 | 2,606 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
import sys
INF = float('inf')
#10**20,2**63,float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
#from collections import defaultdict
def solve():
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LC(): return list(input())
def IC(): return [int(c) for c in input()]
def MI(): return map(int, sys.stdin.readline().split())
N = II()
D = LI()
DP = [0 for _ in range(2 ** N)]
DP[0] = 100
for S in range(2 ** N):
if DP[S] == 0:continue
hp = 1
for s in range(N):
if S >> s & 1 and D[s] <0:
hp += 1
MaxHP = hp*100
for t in range(N):
if S >> t & 1:
continue
if D[t] > 0:
DP[S|1<<t] = max(DP[S|1 << t],min(DP[S] + D[t],MaxHP))
else:
if DP[S]+D[t] <0:
continue
else:
DP[S|1<<t] = max(DP[S]+D[t],DP[S|1<<t])
#print(DP)
print(DP[S])
return
solve()
#sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!!