結果

問題 No.844 split game
ユーザー kotamanegikotamanegi
提出日時 2019-06-28 21:39:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,705 bytes
コンパイル時間 861 ms
コンパイル使用メモリ 105,060 KB
実行使用メモリ 14,064 KB
最終ジャッジ日時 2023-09-14 21:43:03
合計ジャッジ時間 4,583 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
12,332 KB
testcase_01 AC 21 ms
11,992 KB
testcase_02 AC 48 ms
13,524 KB
testcase_03 AC 36 ms
12,820 KB
testcase_04 AC 20 ms
12,228 KB
testcase_05 AC 55 ms
13,556 KB
testcase_06 AC 20 ms
11,944 KB
testcase_07 AC 17 ms
12,028 KB
testcase_08 AC 12 ms
11,696 KB
testcase_09 AC 38 ms
13,248 KB
testcase_10 AC 55 ms
13,808 KB
testcase_11 AC 54 ms
13,584 KB
testcase_12 AC 36 ms
13,176 KB
testcase_13 AC 25 ms
12,316 KB
testcase_14 AC 26 ms
12,284 KB
testcase_15 AC 58 ms
14,064 KB
testcase_16 AC 59 ms
13,760 KB
testcase_17 AC 58 ms
13,852 KB
testcase_18 AC 58 ms
13,988 KB
testcase_19 AC 58 ms
13,832 KB
testcase_20 AC 58 ms
14,056 KB
testcase_21 AC 58 ms
13,768 KB
testcase_22 AC 58 ms
13,760 KB
testcase_23 AC 8 ms
11,368 KB
testcase_24 AC 9 ms
11,412 KB
testcase_25 AC 8 ms
11,324 KB
testcase_26 AC 7 ms
11,264 KB
testcase_27 AC 8 ms
11,400 KB
testcase_28 AC 6 ms
11,336 KB
testcase_29 AC 9 ms
11,388 KB
testcase_30 AC 9 ms
11,468 KB
testcase_31 AC 9 ms
11,556 KB
testcase_32 AC 6 ms
11,188 KB
testcase_33 AC 10 ms
11,420 KB
testcase_34 AC 8 ms
11,356 KB
testcase_35 AC 10 ms
11,372 KB
testcase_36 AC 8 ms
11,464 KB
testcase_37 AC 13 ms
11,620 KB
testcase_38 AC 19 ms
12,340 KB
testcase_39 AC 33 ms
13,208 KB
testcase_40 AC 14 ms
11,820 KB
testcase_41 AC 6 ms
11,300 KB
testcase_42 AC 6 ms
11,140 KB
testcase_43 AC 6 ms
11,124 KB
testcase_44 AC 6 ms
11,140 KB
testcase_45 AC 6 ms
11,192 KB
testcase_46 AC 6 ms
11,332 KB
testcase_47 AC 6 ms
11,236 KB
testcase_48 AC 6 ms
11,188 KB
testcase_49 AC 6 ms
11,368 KB
testcase_50 AC 6 ms
11,216 KB
testcase_51 AC 6 ms
11,144 KB
testcase_52 AC 6 ms
11,144 KB
testcase_53 AC 6 ms
11,356 KB
testcase_54 AC 6 ms
11,120 KB
testcase_55 AC 6 ms
11,196 KB
testcase_56 AC 6 ms
11,236 KB
testcase_57 AC 6 ms
11,212 KB
testcase_58 AC 6 ms
11,304 KB
testcase_59 AC 6 ms
11,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
long long dp[2][200000];
vector<pair<long long,long long>> skipping[200000];
int main(){
#define int long long
	iostream::sync_with_stdio(false);
	int n, m, a;
	cin >> n >> m >> a;
	REP(i, m) {
		long long a, b, c;
		cin >> a >> b >> c;
		a--;
		skipping[a].push_back(make_pair(b, c));
	}
	REP(i, 2) {
		REP(q, 200000) {
			dp[i][q] = -LONG_INF;
		}
	}
	dp[1][0] = 0;
	for (int i = 0; i <= n; ++i) {
		dp[0][i + 1] = max({ dp[0][i + 1], dp[0][i],dp[1][i] });
		for (int q = 0; q < skipping[i].size(); ++q) {
			int next = skipping[i][q].first;
			long long value = skipping[i][q].second;
			int geko = 0;
			if (next != n) {
				geko = a;
			}
			dp[1][next] = max({ dp[1][next],dp[1][i] + value - geko,dp[0][i] + value - a - geko});
		}
	}
	cout << max(dp[0][n + 1], dp[1][n + 1]) << endl;
	return 0;
}
0