結果

問題 No.107 モンスター
ユーザー moharan627moharan627
提出日時 2021-08-21 15:08:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 1,140 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 75,520 KB
最終ジャッジ日時 2024-04-23 06:19:46
合計ジャッジ時間 2,693 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,224 KB
testcase_01 AC 46 ms
52,224 KB
testcase_02 AC 42 ms
52,224 KB
testcase_03 AC 42 ms
52,608 KB
testcase_04 AC 43 ms
51,968 KB
testcase_05 AC 42 ms
51,968 KB
testcase_06 AC 42 ms
52,224 KB
testcase_07 AC 41 ms
51,968 KB
testcase_08 AC 40 ms
52,352 KB
testcase_09 AC 42 ms
52,480 KB
testcase_10 AC 40 ms
52,224 KB
testcase_11 AC 42 ms
52,352 KB
testcase_12 AC 40 ms
52,224 KB
testcase_13 AC 66 ms
69,120 KB
testcase_14 AC 72 ms
70,912 KB
testcase_15 AC 73 ms
70,656 KB
testcase_16 AC 43 ms
52,352 KB
testcase_17 AC 77 ms
70,272 KB
testcase_18 AC 76 ms
69,376 KB
testcase_19 AC 72 ms
69,504 KB
testcase_20 AC 74 ms
70,656 KB
testcase_21 AC 75 ms
71,424 KB
testcase_22 AC 81 ms
74,240 KB
testcase_23 AC 78 ms
73,472 KB
testcase_24 AC 85 ms
75,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)#再帰関数ではコメントにしないこと!!
0