結果

問題 No.107 モンスター
ユーザー chocorusk
提出日時 2020-09-13 11:42:01
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 210 ms / 5,000 ms
コード長 501 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-06-11 20:20:37
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

n=int(readline())
d=list(map(int, readline().split()))
dp=[0]*(1<<n)
dp[0]=100
for i, x in enumerate(dp):
    if x==0:
        continue
    t=sum(y<0 for j, y in enumerate(d) if i&(1<<j))
    for j, y in enumerate(d):
        if i&(1<<j):
            continue
        if x+y>0:
            x1=min(x+y, (t+1)*100)
            if dp[i^(1<<j)]<x1:
                dp[i^(1<<j)]=x1
print(dp[-1])
0