提出 #34404394


ソースコード 拡げる

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <complex>
using namespace std;

typedef long long int ll;

int main() {
    ll n; cin >> n;
    vector<ll> ts(n), xs(n), as(n);
    for(int i = 0; i < n; i++) {
        cin >> ts[i] >> xs[i] >> as[i];
    }

    vector<ll> st(5,-1);
    st[0] = 0;
    int prev = 0;
    for (int i = 0; i < n; i++) {
        vector<ll> nextst(5,-1);
        int dift = ts[i] - prev;
        for (int j = 0; j < 5; j++) {
            ll tmp = -1;
            for(int k=max(j-dift,0); k <= min(j+dift, 4); k++) {
                tmp = max(tmp, st[k]);
            }
            nextst[j] = tmp;
        }
        if (nextst[xs[i]] != -1) {
            nextst[xs[i]] += as[i];
        }
        prev = ts[i];
        st = nextst;
    }
    ll ans = 0;
    for (int i = 0; i < st.size(); i++) {
        ans = max(ans, st[i]);
    }
    cout << ans << endl;
    return 0;
}

提出情報

提出日時
問題 D - Snuke Panic (1D)
ユーザ tomoya
言語 C++ (Clang 10.0.0)
得点 400
コード長 998 Byte
結果 AC
実行時間 166 ms
メモリ 5244 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 30
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 9 ms 3056 KiB
hand_02.txt AC 2 ms 3100 KiB
min.txt AC 2 ms 3136 KiB
random_01.txt AC 165 ms 5184 KiB
random_02.txt AC 166 ms 5244 KiB
random_03.txt AC 161 ms 5096 KiB
random_04.txt AC 161 ms 5244 KiB
random_05.txt AC 146 ms 4860 KiB
random_06.txt AC 147 ms 4872 KiB
random_07.txt AC 88 ms 3804 KiB
random_08.txt AC 87 ms 3768 KiB
random_09.txt AC 22 ms 3316 KiB
random_10.txt AC 24 ms 3324 KiB
random_11.txt AC 5 ms 3168 KiB
random_12.txt AC 5 ms 3020 KiB
random_13.txt AC 165 ms 5008 KiB
random_14.txt AC 163 ms 5108 KiB
random_15.txt AC 161 ms 5116 KiB
random_16.txt AC 161 ms 5056 KiB
random_17.txt AC 148 ms 4744 KiB
random_18.txt AC 146 ms 4748 KiB
random_19.txt AC 87 ms 3920 KiB
random_20.txt AC 87 ms 3860 KiB
random_21.txt AC 26 ms 3264 KiB
random_22.txt AC 22 ms 3236 KiB
random_23.txt AC 8 ms 3120 KiB
random_24.txt AC 7 ms 3016 KiB
sample_01.txt AC 2 ms 3172 KiB
sample_02.txt AC 2 ms 3036 KiB
sample_03.txt AC 3 ms 3148 KiB