Submission #34385139


Source Code Expand

#include"bits/stdc++.h"

using namespace std;

long long f[101000][5];

int main() {
    // freopen("A.in" , "r" , stdin);
    // freopen("A.out" , "w" , stdout);
    int n;
    cin >> n;
    vector<int> t(n+1), x(n+1), a(n+1);
    for (int i = 1; i <= n; ++i) cin >> t[i] >> x[i] >> a[i];
    t[0] = 0;
    f[0][0] = 0;
    for (int i = 1; i < 5; ++i) f[0][i] = -1;
    for (int i = 1; i <= n; ++i) {
        int dt = t[i] - t[i-1];
        for (int j = 0; j < 5; ++j) {
            f[i][j] = -1;
            for (int k = 0; k < 5; ++k) {
                if (abs(j-k) <= dt && f[i-1][k] != -1) {
                    f[i][j] = max(f[i][j], f[i-1][k] + (x[i]==j?a[i]:0));
                }
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < 5; ++i) ans = max(ans, f[n][i]);
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Snuke Panic (1D)
User ZzZZCHS
Language C++ (GCC 9.2.1)
Score 400
Code Size 874 Byte
Status AC
Exec Time 76 ms
Memory 8204 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 30
Set Name Test Cases
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
Case Name Status Exec Time Memory
hand_01.txt AC 6 ms 3428 KiB
hand_02.txt AC 2 ms 3588 KiB
min.txt AC 2 ms 3408 KiB
random_01.txt AC 76 ms 8204 KiB
random_02.txt AC 72 ms 8180 KiB
random_03.txt AC 74 ms 8100 KiB
random_04.txt AC 71 ms 8116 KiB
random_05.txt AC 66 ms 7636 KiB
random_06.txt AC 66 ms 7656 KiB
random_07.txt AC 42 ms 5892 KiB
random_08.txt AC 42 ms 5800 KiB
random_09.txt AC 13 ms 4128 KiB
random_10.txt AC 15 ms 3920 KiB
random_11.txt AC 4 ms 3532 KiB
random_12.txt AC 4 ms 3480 KiB
random_13.txt AC 71 ms 8104 KiB
random_14.txt AC 71 ms 8036 KiB
random_15.txt AC 71 ms 8084 KiB
random_16.txt AC 75 ms 8164 KiB
random_17.txt AC 67 ms 7556 KiB
random_18.txt AC 65 ms 7556 KiB
random_19.txt AC 42 ms 5736 KiB
random_20.txt AC 43 ms 5840 KiB
random_21.txt AC 13 ms 4092 KiB
random_22.txt AC 13 ms 4004 KiB
random_23.txt AC 3 ms 3636 KiB
random_24.txt AC 3 ms 3564 KiB
sample_01.txt AC 3 ms 3620 KiB
sample_02.txt AC 2 ms 3512 KiB
sample_03.txt AC 2 ms 3580 KiB