結果

問題 No.844 split game
ユーザー tarattata1tarattata1
提出日時 2019-06-29 13:10:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,111 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 79,964 KB
実行使用メモリ 8,472 KB
最終ジャッジ日時 2023-09-14 23:12:11
合計ジャッジ時間 4,066 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
4,744 KB
testcase_01 AC 17 ms
7,120 KB
testcase_02 AC 37 ms
5,796 KB
testcase_03 AC 30 ms
6,892 KB
testcase_04 AC 15 ms
4,520 KB
testcase_05 AC 41 ms
7,420 KB
testcase_06 AC 14 ms
4,512 KB
testcase_07 AC 12 ms
6,056 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 28 ms
4,388 KB
testcase_10 AC 43 ms
6,840 KB
testcase_11 AC 43 ms
8,144 KB
testcase_12 AC 27 ms
4,380 KB
testcase_13 AC 18 ms
4,376 KB
testcase_14 AC 21 ms
6,032 KB
testcase_15 AC 46 ms
8,472 KB
testcase_16 AC 46 ms
8,356 KB
testcase_17 AC 48 ms
8,384 KB
testcase_18 AC 55 ms
8,420 KB
testcase_19 AC 44 ms
8,356 KB
testcase_20 AC 46 ms
8,384 KB
testcase_21 AC 46 ms
8,440 KB
testcase_22 AC 46 ms
8,384 KB
testcase_23 AC 3 ms
4,384 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 5 ms
4,380 KB
testcase_31 AC 4 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 5 ms
4,380 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 5 ms
4,380 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 7 ms
4,380 KB
testcase_38 AC 13 ms
4,380 KB
testcase_39 AC 28 ms
4,692 KB
testcase_40 AC 11 ms
5,276 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 2 ms
4,384 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 1 ms
4,376 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,m,a;
    scanf("%d%d%d", &n, &m, &a);

    vector<vector<pair<int,int> > > v(n+1);
    int i;
    for(i=0; i<m; i++) {
        int l,r,p;
        scanf("%d%d%d", &l, &r, &p); l--;
        v[r].push_back(make_pair(l, p));
    }

    vector<ll> dp(n+1);
    vector<ll> sdp(n+1);
    dp[0]=0;
    for(i=1; i<=n; i++) {
        dp[i]=sdp[i-1]-(i==n? 0: a);
        int k;
        for(k=0; k<(int)v[i].size(); k++) {
            dp[i]=MAX(dp[i],dp[v[i][k].first]+v[i][k].second-(i==n? 0: a));
        }
        sdp[i]=MAX(sdp[i-1],dp[i]);
    }
    printf("%lld\n", sdp[n]);

    return 0;
}
0