結果

問題 No.844 split game
ユーザー koyoprokoyopro
提出日時 2019-12-23 00:38:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,562 bytes
コンパイル時間 1,442 ms
コンパイル使用メモリ 153,656 KB
実行使用メモリ 19,440 KB
最終ジャッジ日時 2023-10-12 23:18:28
合計ジャッジ時間 8,367 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
9,340 KB
testcase_01 AC 65 ms
13,944 KB
testcase_02 AC 128 ms
13,088 KB
testcase_03 AC 103 ms
14,756 KB
testcase_04 AC 49 ms
8,788 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 185 ms
19,120 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 180 ms
19,096 KB
testcase_19 WA -
testcase_20 AC 172 ms
19,212 KB
testcase_21 AC 179 ms
19,308 KB
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 4 ms
4,348 KB
testcase_29 AC 10 ms
4,696 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 4 ms
4,348 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 13 ms
4,540 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 41 ms
6,836 KB
testcase_39 AC 93 ms
10,528 KB
testcase_40 AC 40 ms
9,632 KB
testcase_41 AC 2 ms
4,352 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 2 ms
4,352 KB
testcase_46 AC 1 ms
4,356 KB
testcase_47 AC 2 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 1 ms
4,348 KB
testcase_50 AC 2 ms
4,352 KB
testcase_51 AC 1 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 WA -
testcase_54 AC 1 ms
4,352 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 1 ms
4,352 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 AC 1 ms
4,352 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;
struct Memo {
    int lastPos; // 0 ~ N
    int score;
};

signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin >> N >> M >> A;
    Memo 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].lastPos = 0;
    dp[0].score = 0;
    REP(i, N+1) {
        if (i > 0) dp[i] = dp[i-1];
        for (auto range:MAP[i]) {
            int score = dp[range.l].score + range.p;
            if (range.r != N) score -= A;
            if (dp[range.l].lastPos != range.l) score -= A;
            if (dp[i].score < score) {
                dp[i].score = score;
                dp[i].lastPos = range.r;
            }
        }
    }
    cout << dp[N].score << endl;
    
    return 0;
}
0