結果

問題 No.107 モンスター
ユーザー 6soukiti296soukiti29
提出日時 2017-08-23 22:26:58
言語 Nim
(2.0.2)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 713 bytes
コンパイル時間 3,042 ms
コンパイル使用メモリ 68,736 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 14:58:33
合計ジャッジ時間 4,106 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'math' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,math,algorithm

type
    yuusha = tuple[maxhp, hp : int] 

var
    N = stdin.readline.parseInt
    A = stdin.readline.split.map(parseInt)
    hp = 100
    maxhp = 100
    dp : array[1 shl 16, yuusha]
    
A.sort(system.cmp)
dp[0] = (100,100)
for i in 0..<(1 shl N):
    if dp[i].hp <= 0:
        continue
    for k in 0..<N:
        if (i and (1 shl k)) == 0:
            var p = (i + (1 shl k))
            if A[k] < 0:
                dp[p].hp = max(dp[i].hp + A[k], dp[p].hp)
                dp[p].maxhp = dp[i].maxhp + 100
            else:
                dp[p].maxhp = dp[i].maxhp
                dp[p].hp = min(max(dp[i].hp + A[k], dp[p].hp), dp[i].maxhp)
echo dp[(1 shl N) - 1].hp
0