結果

問題 No.844 split game
ユーザー 6soukiti296soukiti29
提出日時 2019-06-28 22:39:46
言語 Nim
(2.0.2)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 3,975 ms
コンパイル使用メモリ 71,928 KB
実行使用メモリ 15,896 KB
最終ジャッジ日時 2023-09-14 22:25:27
合計ジャッジ時間 9,170 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
8,380 KB
testcase_01 AC 39 ms
7,676 KB
testcase_02 AC 110 ms
13,480 KB
testcase_03 AC 75 ms
10,336 KB
testcase_04 AC 41 ms
7,428 KB
testcase_05 AC 112 ms
13,952 KB
testcase_06 AC 35 ms
6,468 KB
testcase_07 AC 27 ms
6,580 KB
testcase_08 AC 17 ms
5,164 KB
testcase_09 AC 92 ms
12,212 KB
testcase_10 AC 119 ms
14,072 KB
testcase_11 AC 113 ms
14,232 KB
testcase_12 AC 91 ms
12,088 KB
testcase_13 AC 54 ms
7,932 KB
testcase_14 AC 50 ms
8,632 KB
testcase_15 AC 123 ms
15,872 KB
testcase_16 AC 123 ms
15,868 KB
testcase_17 AC 123 ms
15,872 KB
testcase_18 AC 122 ms
15,820 KB
testcase_19 AC 123 ms
15,872 KB
testcase_20 AC 123 ms
15,896 KB
testcase_21 AC 123 ms
15,860 KB
testcase_22 AC 123 ms
15,896 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 11 ms
4,380 KB
testcase_25 AC 7 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 10 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 9 ms
4,376 KB
testcase_30 AC 11 ms
4,380 KB
testcase_31 AC 10 ms
4,380 KB
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 14 ms
4,396 KB
testcase_34 AC 9 ms
4,380 KB
testcase_35 AC 17 ms
4,492 KB
testcase_36 AC 11 ms
4,380 KB
testcase_37 AC 25 ms
5,524 KB
testcase_38 AC 46 ms
7,708 KB
testcase_39 AC 95 ms
12,656 KB
testcase_40 AC 26 ms
6,324 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 1 ms
4,376 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils,algorithm
var
    N,M,A : int
    dp : array[-1..100010, array[2,int]]
(N, M, A) = stdin.readline.split.map(parseInt)
type
    t = tuple[l, r, p : int]
var ts = newSeq[t](0)
var l, r, p : int
for m in 1..M:
    (l, r, p) = stdin.readline.split.map(parseInt)
    ts.add((l, r, p))

ts = ts.sortedByIt(it.r)
int p = 0
for i in 1..N:
    dp[i + 1][0] = max(dp[i][0], dp[i][1])
    dp[i + 1][1] = max(dp[i][0], dp[i][1]) - A
    while p < M and ts[p].r == i:
        var a = ts[p]
        dp[i + 1][1] = max(dp[a.l][1] + a.p - A, dp[i + 1][1])
        p += 1
echo max(dp[N + 1][0],dp[N + 1][1] + A)

0