結果

問題 No.844 split game
ユーザー koyoprokoyopro
提出日時 2019-12-23 01:02:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,339 bytes
コンパイル時間 2,125 ms
コンパイル使用メモリ 153,780 KB
実行使用メモリ 18,408 KB
最終ジャッジ日時 2023-10-12 23:51:02
合計ジャッジ時間 7,667 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
9,104 KB
testcase_01 AC 66 ms
13,288 KB
testcase_02 AC 137 ms
12,776 KB
testcase_03 AC 107 ms
14,264 KB
testcase_04 AC 50 ms
8,300 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 184 ms
18,292 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 187 ms
18,296 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 4 ms
4,348 KB
testcase_27 WA -
testcase_28 AC 5 ms
4,348 KB
testcase_29 AC 10 ms
4,592 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 4 ms
4,352 KB
testcase_33 AC 12 ms
4,356 KB
testcase_34 AC 7 ms
4,348 KB
testcase_35 AC 14 ms
4,348 KB
testcase_36 AC 8 ms
4,352 KB
testcase_37 AC 19 ms
4,864 KB
testcase_38 AC 42 ms
6,692 KB
testcase_39 AC 95 ms
10,336 KB
testcase_40 AC 38 ms
9,200 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,352 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 1 ms
4,348 KB
testcase_47 WA -
testcase_48 AC 2 ms
4,352 KB
testcase_49 WA -
testcase_50 AC 1 ms
4,348 KB
testcase_51 WA -
testcase_52 AC 2 ms
4,348 KB
testcase_53 AC 1 ms
4,348 KB
testcase_54 WA -
testcase_55 AC 1 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 1 ms
4,348 KB
testcase_58 AC 1 ms
4,352 KB
testcase_59 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

/*================================*/

int N, M, A;
struct Range {
    int l;
    int r;
    int p;
};
map<int, vector<Range>> MAP;

signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin >> N >> M >> A;
    int dp[N+1];
    REP(i, M) {
        Range range = *new Range();
        cin >> range.l >> range.r >> range.p;
        range.l--;
        MAP[range.r].push_back(range);
    }
    dp[0] = 0;
    REP(i, N+1) {
        if (i == 0) continue;
        dp[i] = dp[i-1] - A;
        for (auto r: MAP[i]) {
            int score = dp[r.l] + r.p;
            if (i != N) score -= A;
            dp[i] = max(dp[i], score);
        }
    }
    cout << *max_element(dp, dp + N + 1) << endl;
    
    return 0;
}
0