結果

問題 No.844 split game
ユーザー mkawa2mkawa2
提出日時 2019-07-11 08:57:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 892 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 36,892 KB
最終ジャッジ日時 2024-04-24 20:12:48
合計ジャッジ時間 18,809 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 331 ms
21,248 KB
testcase_01 AC 260 ms
19,232 KB
testcase_02 AC 754 ms
33,440 KB
testcase_03 AC 499 ms
26,364 KB
testcase_04 AC 270 ms
18,944 KB
testcase_05 AC 781 ms
33,872 KB
testcase_06 AC 247 ms
18,308 KB
testcase_07 AC 192 ms
17,160 KB
testcase_08 AC 123 ms
14,464 KB
testcase_09 AC 601 ms
28,952 KB
testcase_10 AC 797 ms
35,176 KB
testcase_11 AC 798 ms
34,564 KB
testcase_12 AC 586 ms
28,820 KB
testcase_13 AC 373 ms
21,712 KB
testcase_14 AC 331 ms
21,404 KB
testcase_15 AC 838 ms
35,336 KB
testcase_16 AC 876 ms
36,732 KB
testcase_17 AC 888 ms
36,792 KB
testcase_18 AC 858 ms
35,208 KB
testcase_19 AC 841 ms
35,904 KB
testcase_20 AC 839 ms
35,280 KB
testcase_21 AC 881 ms
36,856 KB
testcase_22 AC 892 ms
36,892 KB
testcase_23 AC 51 ms
11,776 KB
testcase_24 AC 85 ms
12,800 KB
testcase_25 AC 58 ms
12,032 KB
testcase_26 AC 38 ms
11,264 KB
testcase_27 AC 75 ms
12,544 KB
testcase_28 AC 32 ms
11,008 KB
testcase_29 AC 70 ms
12,416 KB
testcase_30 AC 83 ms
12,800 KB
testcase_31 AC 76 ms
12,416 KB
testcase_32 AC 33 ms
11,264 KB
testcase_33 AC 88 ms
12,928 KB
testcase_34 AC 63 ms
12,032 KB
testcase_35 AC 104 ms
13,440 KB
testcase_36 AC 71 ms
12,416 KB
testcase_37 AC 142 ms
14,848 KB
testcase_38 AC 298 ms
19,584 KB
testcase_39 AC 618 ms
28,620 KB
testcase_40 AC 178 ms
15,976 KB
testcase_41 AC 27 ms
10,624 KB
testcase_42 AC 25 ms
10,880 KB
testcase_43 AC 26 ms
10,752 KB
testcase_44 AC 26 ms
10,752 KB
testcase_45 AC 25 ms
10,752 KB
testcase_46 AC 27 ms
10,752 KB
testcase_47 AC 25 ms
10,624 KB
testcase_48 AC 25 ms
10,880 KB
testcase_49 AC 26 ms
10,752 KB
testcase_50 AC 26 ms
10,880 KB
testcase_51 AC 26 ms
10,752 KB
testcase_52 AC 26 ms
10,752 KB
testcase_53 AC 27 ms
10,752 KB
testcase_54 AC 25 ms
10,752 KB
testcase_55 AC 27 ms
10,752 KB
testcase_56 AC 27 ms
10,752 KB
testcase_57 AC 27 ms
10,752 KB
testcase_58 AC 27 ms
10,880 KB
testcase_59 AC 26 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter

def update(i, x):
    while i < n + 1:
        if x > bit[i]:
            bit[i] = x
        i += i & -i

def get(i):
    mx = 0
    while i > 0:
        if mx < bit[i]:
            mx = bit[i]
        i -= i & -i
    return mx

n, m, a = map(int, input().split())
ku = [list(map(int, input().split())) for _ in range(m)]
ku.sort(key=itemgetter(1))
bit = [0] * (n + 1)
dp = [-a] * (n + 1)
for l, r, p in ku:
    if l - 1:
        dp[r] = max(dp[l - 1] + p - a, get(l - 1) + p - 2 * a, dp[r])
        update(r, dp[r])
    else:
        dp[r] = max(p - a, dp[r])
        update(r, dp[r])
update(n,dp[n]+a)
print(get(n))
0