Submission #49415711


Source Code Expand

// LUOGU_RID: 143449904
#include <iostream>
#include <algorithm>
using namespace std;
using LL = long long;

const LL INF = 0x3f3f3f3f3f3f3f3f;
const int N = 100000;
LL dp[5][N + 3], x[N + 3], a[N + 3];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	for(int t, i, j; n--; ) {
		cin >> t >> i >> j;
		x[t] = i;
		a[t] = j;
	}
	for(int i = 1; i < 5; ++i)
		dp[i][0] = -INF;
	for(int t = 1; t <= N; ++t) {
		for(int i = 0; i < 5; ++i) {
			dp[i][t] = dp[i][t - 1];
			if(i != 0)
				dp[i][t] = max(dp[i][t], dp[i - 1][t - 1]);
			if(i != 4)
				dp[i][t] = max(dp[i][t], dp[i + 1][t - 1]);
		}
		dp[x[t]][t] += a[t];
	}
	LL ans = 0;
	for(int i = 0; i < 5; ++i)
		ans = max(ans, dp[i][N]);
	cout << ans;
	return 0;
}

Submission Info

Submission Time
Task D - Snuke Panic (1D)
User TigerTanWQY
Language C++ 17 (gcc 12.2)
Score 400
Code Size 798 Byte
Status AC
Exec Time 15 ms
Memory 8988 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 3 ms 7364 KiB
hand_02.txt AC 3 ms 7432 KiB
min.txt AC 2 ms 7288 KiB
random_01.txt AC 15 ms 8916 KiB
random_02.txt AC 14 ms 8924 KiB
random_03.txt AC 14 ms 8860 KiB
random_04.txt AC 15 ms 8864 KiB
random_05.txt AC 13 ms 8988 KiB
random_06.txt AC 13 ms 8852 KiB
random_07.txt AC 9 ms 8908 KiB
random_08.txt AC 8 ms 8880 KiB
random_09.txt AC 4 ms 8860 KiB
random_10.txt AC 4 ms 8916 KiB
random_11.txt AC 3 ms 8920 KiB
random_12.txt AC 3 ms 8876 KiB
random_13.txt AC 14 ms 8788 KiB
random_14.txt AC 14 ms 8928 KiB
random_15.txt AC 15 ms 8928 KiB
random_16.txt AC 14 ms 8876 KiB
random_17.txt AC 13 ms 8928 KiB
random_18.txt AC 13 ms 8924 KiB
random_19.txt AC 8 ms 8864 KiB
random_20.txt AC 8 ms 8880 KiB
random_21.txt AC 4 ms 8980 KiB
random_22.txt AC 4 ms 8848 KiB
random_23.txt AC 3 ms 8908 KiB
random_24.txt AC 3 ms 8908 KiB
sample_01.txt AC 2 ms 7368 KiB
sample_02.txt AC 3 ms 7336 KiB
sample_03.txt AC 3 ms 7364 KiB