結果

問題 No.107 モンスター
ユーザー efunyoefunyo
提出日時 2020-03-27 19:22:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 1,319 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 86,764 KB
実行使用メモリ 77,908 KB
最終ジャッジ日時 2023-08-30 16:43:56
合計ジャッジ時間 4,785 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,304 KB
testcase_01 AC 98 ms
71,428 KB
testcase_02 AC 96 ms
71,440 KB
testcase_03 AC 96 ms
71,680 KB
testcase_04 AC 95 ms
71,460 KB
testcase_05 AC 96 ms
71,428 KB
testcase_06 AC 96 ms
71,476 KB
testcase_07 AC 97 ms
71,468 KB
testcase_08 AC 95 ms
71,464 KB
testcase_09 AC 98 ms
71,580 KB
testcase_10 AC 95 ms
71,644 KB
testcase_11 AC 100 ms
71,460 KB
testcase_12 AC 105 ms
71,588 KB
testcase_13 AC 124 ms
77,404 KB
testcase_14 AC 128 ms
77,644 KB
testcase_15 AC 129 ms
77,520 KB
testcase_16 AC 97 ms
71,460 KB
testcase_17 AC 122 ms
77,396 KB
testcase_18 AC 118 ms
77,908 KB
testcase_19 AC 120 ms
77,540 KB
testcase_20 AC 126 ms
77,816 KB
testcase_21 AC 127 ms
77,484 KB
testcase_22 AC 134 ms
77,612 KB
testcase_23 AC 131 ms
77,808 KB
testcase_24 AC 129 ms
77,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#https://yukicoder.me/problems/102

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    D = list(map(int, input().split()))
    dp = [0]*(1<<N)
    mod = 10**4

    #dp[s]:sまで倒したときの体力と最大体力
    #         値%modが体力/値//modが最大体力
    dp[0] = 100 + 100*mod
    for i in range(1<<N):
        if dp[i] == 0:
            continue
        for j in range(N):
            hp = dp[i] % mod
            mhp = dp[i] // mod
            if i&(1<<j):
                continue
            if D[j] < 0:
                if hp+D[j] <= 0:
                    dp[i|(1<<j)] = 0
                    continue
                else:
                    hp += D[j]
                    mhp += 100
            else:
                hp = min(mhp, hp+D[j])
            dp[i|(1<<j)] = max(hp, dp[i|(1<<j)]%mod) + mhp*mod
    print(dp[-1]%mod)

if __name__ == '__main__':
    main()
0