結果

問題 No.844 split game
ユーザー yuyayuya
提出日時 2019-06-29 12:35:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 1,918 bytes
コンパイル時間 930 ms
コンパイル使用メモリ 103,716 KB
実行使用メモリ 14,924 KB
最終ジャッジ日時 2023-09-14 23:12:17
合計ジャッジ時間 5,530 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
7,588 KB
testcase_01 AC 34 ms
10,048 KB
testcase_02 AC 105 ms
10,964 KB
testcase_03 AC 70 ms
11,224 KB
testcase_04 AC 35 ms
7,016 KB
testcase_05 AC 112 ms
13,072 KB
testcase_06 AC 34 ms
6,796 KB
testcase_07 AC 26 ms
8,456 KB
testcase_08 AC 16 ms
5,304 KB
testcase_09 AC 88 ms
8,552 KB
testcase_10 AC 117 ms
12,816 KB
testcase_11 AC 112 ms
13,996 KB
testcase_12 AC 89 ms
8,336 KB
testcase_13 AC 51 ms
6,600 KB
testcase_14 AC 47 ms
8,976 KB
testcase_15 AC 124 ms
14,924 KB
testcase_16 AC 125 ms
14,852 KB
testcase_17 AC 122 ms
14,848 KB
testcase_18 AC 123 ms
14,920 KB
testcase_19 AC 124 ms
14,752 KB
testcase_20 AC 125 ms
14,792 KB
testcase_21 AC 123 ms
14,884 KB
testcase_22 AC 124 ms
14,912 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 9 ms
4,376 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 8 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 7 ms
4,380 KB
testcase_30 AC 9 ms
4,380 KB
testcase_31 AC 7 ms
4,380 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 12 ms
4,376 KB
testcase_34 AC 7 ms
4,380 KB
testcase_35 AC 14 ms
4,380 KB
testcase_36 AC 8 ms
4,380 KB
testcase_37 AC 21 ms
5,048 KB
testcase_38 AC 37 ms
6,076 KB
testcase_39 AC 81 ms
9,452 KB
testcase_40 AC 22 ms
7,388 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 1 ms
4,376 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define MX 100010


template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//






int main()
{
        int n,m,a;
        cin >> n >> m >> a;
        vector<map<int,Int>> ma(n+1);
        for(int i = 0; i < m; i++)
        {
                int l,r,p;
                cin >> l >> r >> p;
                ma[r][l] += p;
        }

        vector<Int> dp(n+2, -1e17);
        dp[0] = 0;
        Int tmp_maxi = 0;
        for(int i = 1; i < n+1; i++)
        {
                int cost = a;
                if(i == n) cost = 0;
                for(auto pa : ma[i])
                {
                        chmax(dp[i], dp[pa.first-1] + pa.second- cost);
                }
                chmax(dp[i], tmp_maxi-a);
                chmax(tmp_maxi, dp[i]);
        }
        cout << *max_element(all(dp)) << endl;
        return 0;
}





















0