結果

問題 No.844 split game
ユーザー QCFiumQCFium
提出日時 2019-06-28 21:59:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 764 bytes
コンパイル時間 2,501 ms
コンパイル使用メモリ 188,032 KB
実行使用メモリ 15,064 KB
最終ジャッジ日時 2023-09-14 21:58:21
合計ジャッジ時間 33,366 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 267 ms
7,792 KB
testcase_01 AC 1,683 ms
10,264 KB
testcase_02 AC 368 ms
11,112 KB
testcase_03 AC 1,294 ms
11,380 KB
testcase_04 AC 240 ms
7,284 KB
testcase_05 AC 1,291 ms
13,196 KB
testcase_06 AC 282 ms
7,100 KB
testcase_07 AC 1,237 ms
8,920 KB
testcase_08 AC 138 ms
5,716 KB
testcase_09 AC 96 ms
8,632 KB
testcase_10 AC 875 ms
12,708 KB
testcase_11 AC 1,913 ms
14,056 KB
testcase_12 AC 77 ms
8,476 KB
testcase_13 AC 56 ms
6,764 KB
testcase_14 AC 840 ms
9,324 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 24 ms
4,392 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 7 ms
4,376 KB
testcase_27 AC 6 ms
4,376 KB
testcase_28 AC 15 ms
4,380 KB
testcase_29 AC 23 ms
4,652 KB
testcase_30 AC 23 ms
4,708 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 10 ms
4,376 KB
testcase_33 AC 8 ms
4,376 KB
testcase_34 AC 5 ms
4,380 KB
testcase_35 AC 9 ms
4,460 KB
testcase_36 AC 5 ms
4,376 KB
testcase_37 AC 12 ms
4,700 KB
testcase_38 AC 28 ms
6,252 KB
testcase_39 AC 92 ms
9,340 KB
testcase_40 AC 567 ms
7,576 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx")
#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