Submission #34404598


Source Code Expand

/*
 * @Date: 2022-08-27 21:25:05
 * @LastEditors: 1048576
 * @FilePath: \code\D_-_Snuke_Panic_1_D.cpp
 * @MajorAlgorithm: 
 */
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sz[100005][5], f[100005][5];
int n, mx;
signed main() {
    cin >> n;
    while (n --) {
        int x, y, z;
        cin >> x >> y >> z;
        sz[x][y] = z;
        mx = max(mx, x);
    }
    for (int i=1;i<=mx;++i) {
        if(i>=0)f[i][0]=max(f[i-1][0],f[i-1][1])+sz[i][0];
        if(i>=1)f[i][1]=max(f[i-1][0],max(f[i-1][1],f[i-1][2]))+sz[i][1];
        if(i>=2)f[i][2]=max(f[i-1][1],max(f[i-1][2],f[i-1][3]))+sz[i][2];
        if(i>=3)f[i][3]=max(f[i-1][2],max(f[i-1][3],f[i-1][4]))+sz[i][3];
        if(i>=4)f[i][4]=max(f[i-1][3],f[i-1][4])+sz[i][4];
    }
    int ans=0;
    for (int i=0;i<5;++i) ans=max(f[mx][i], ans);
    cout << ans << endl;
}

Submission Info

Submission Time
Task D - Snuke Panic (1D)
User luhouxi
Language C++ (GCC 9.2.1)
Score 400
Code Size 886 Byte
Status AC
Exec Time 71 ms
Memory 11396 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 7 ms 3584 KiB
hand_02.txt AC 2 ms 3580 KiB
min.txt AC 2 ms 3584 KiB
random_01.txt AC 71 ms 11368 KiB
random_02.txt AC 70 ms 11336 KiB
random_03.txt AC 70 ms 11244 KiB
random_04.txt AC 70 ms 11252 KiB
random_05.txt AC 66 ms 11384 KiB
random_06.txt AC 64 ms 11244 KiB
random_07.txt AC 44 ms 11248 KiB
random_08.txt AC 43 ms 11252 KiB
random_09.txt AC 17 ms 11380 KiB
random_10.txt AC 18 ms 11396 KiB
random_11.txt AC 9 ms 9856 KiB
random_12.txt AC 13 ms 9848 KiB
random_13.txt AC 70 ms 11196 KiB
random_14.txt AC 70 ms 11380 KiB
random_15.txt AC 70 ms 11324 KiB
random_16.txt AC 69 ms 11200 KiB
random_17.txt AC 65 ms 11252 KiB
random_18.txt AC 66 ms 11340 KiB
random_19.txt AC 41 ms 11200 KiB
random_20.txt AC 43 ms 11248 KiB
random_21.txt AC 21 ms 11328 KiB
random_22.txt AC 18 ms 11256 KiB
random_23.txt AC 10 ms 9748 KiB
random_24.txt AC 10 ms 9760 KiB
sample_01.txt AC 4 ms 3628 KiB
sample_02.txt AC 2 ms 3440 KiB
sample_03.txt AC 3 ms 3388 KiB