結果

問題 No.844 split game
ユーザー QCFiumQCFium
提出日時 2019-06-28 22:00:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,464 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 2,851 ms
コンパイル使用メモリ 187,972 KB
実行使用メモリ 14,832 KB
最終ジャッジ日時 2023-09-14 21:58:48
合計ジャッジ時間 24,862 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 185 ms
7,924 KB
testcase_01 AC 1,168 ms
10,284 KB
testcase_02 AC 278 ms
11,008 KB
testcase_03 AC 854 ms
11,380 KB
testcase_04 AC 170 ms
7,456 KB
testcase_05 AC 883 ms
13,012 KB
testcase_06 AC 194 ms
7,148 KB
testcase_07 AC 816 ms
8,908 KB
testcase_08 AC 96 ms
5,740 KB
testcase_09 AC 85 ms
8,696 KB
testcase_10 AC 617 ms
12,968 KB
testcase_11 AC 1,290 ms
14,116 KB
testcase_12 AC 70 ms
8,492 KB
testcase_13 AC 46 ms
6,736 KB
testcase_14 AC 555 ms
9,160 KB
testcase_15 AC 1,397 ms
14,808 KB
testcase_16 AC 1,403 ms
14,812 KB
testcase_17 AC 1,415 ms
14,768 KB
testcase_18 AC 1,407 ms
14,768 KB
testcase_19 AC 1,410 ms
14,816 KB
testcase_20 AC 1,434 ms
14,768 KB
testcase_21 AC 1,464 ms
14,832 KB
testcase_22 AC 1,438 ms
14,736 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 18 ms
4,400 KB
testcase_25 AC 5 ms
4,376 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 10 ms
4,376 KB
testcase_29 AC 18 ms
4,440 KB
testcase_30 AC 18 ms
4,412 KB
testcase_31 AC 7 ms
4,380 KB
testcase_32 AC 7 ms
4,376 KB
testcase_33 AC 8 ms
4,380 KB
testcase_34 AC 5 ms
4,376 KB
testcase_35 AC 9 ms
4,380 KB
testcase_36 AC 6 ms
4,376 KB
testcase_37 AC 12 ms
4,804 KB
testcase_38 AC 24 ms
6,252 KB
testcase_39 AC 73 ms
9,316 KB
testcase_40 AC 375 ms
7,580 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 2 ms
4,376 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int a = ri();
	int l[m], r[m], p[m];
	for (int i = 0; i < m; i++) l[i] = ri() - 1, r[i] = ri() - 1, p[i] = ri();
	std::map<int, int> ranges[n];
	for (int i = 0; i < m; i++) ranges[l[i]].insert({r[i], p[i]});
	int64_t dp[n + 1];
	for (int i = 0; i <= n; i++) dp[i] = -1000000007;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			dp[j] = std::max(dp[j], dp[i] - a);
		}
		for (auto j : ranges[i]) dp[j.first + 1] = std::max(dp[j.first + 1], dp[i] - a + j.second);
	}
	std::cout << dp[n] + a << std::endl;
	
	return 0;
}

0