結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
9,392 KB
testcase_01 AC 82 ms
13,992 KB
testcase_02 AC 172 ms
13,064 KB
testcase_03 AC 141 ms
14,832 KB
testcase_04 AC 62 ms
8,608 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 241 ms
19,224 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 238 ms
19,048 KB
testcase_19 WA -
testcase_20 AC 237 ms
19,108 KB
testcase_21 AC 232 ms
19,224 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 5 ms
4,352 KB
testcase_27 WA -
testcase_28 AC 5 ms
4,352 KB
testcase_29 AC 11 ms
4,828 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,488 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 50 ms
6,852 KB
testcase_39 AC 111 ms
10,524 KB
testcase_40 AC 46 ms
9,692 KB
testcase_41 AC 2 ms
4,480 KB
testcase_42 AC 2 ms
4,352 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 2 ms
4,348 KB
testcase_47 AC 1 ms
4,352 KB
testcase_48 AC 2 ms
4,352 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 AC 1 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 AC 1 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 1 ms
4,352 KB
testcase_56 AC 1 ms
4,352 KB
testcase_57 AC 1 ms
4,352 KB
testcase_58 AC 1 ms
4,348 KB
testcase_59 AC 1 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;
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 (i != N) score -= A;
            int lastPos = dp[range.l].lastPos;
            if (lastPos != range.l) {
                score -= A;
                for (auto r : MAP[range.l]) {
                    if (lastPos == r.l) {
                        score += r.p;
                    }
                }
            }
            if (dp[i].score < score) {
                dp[i].score = score;
                dp[i].lastPos = i;
            }
        }
    }
    cout << dp[N].score << endl;
    
    return 0;
}
0