/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 6.316 MiB
#2 Wrong Answer 4ms 6.539 MiB
#3 Wrong Answer 81ms 6.645 MiB

Code

// BISMILLAH

#include "bits/stdc++.h"

#define ll long long int
const int mxN = 500005, inf = 1000000005;

int N, a[2][mxN];
ll dp[2][mxN];

void init(int N) {
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = 0;
		}
	}
}

signed main() {
	int testCases=1;
	scanf("%lld",&testCases);
	// std::cin >> testCases;
	
	for (int T = 1; T <= testCases; T++) {
		scanf("%d", &N);
		for (int i = 0; i < 2; i++) {
			for (int j = 0,x; j < N; j++) {
				scanf("%d", &x);
				a[i][j] = x;
				if (j > 0 && j+1 < N) a[i][j] = std::max(x, -j - 1);
			}
		}
		init(N);
		dp[0][0] = a[0][0];
		for (int j = 1; j < N; j++) {
			dp[0][j] = dp[0][j - 1] + a[0][j];
		}
		dp[1][0] = dp[0][0] + a[1][0];
		for (int j = 1; j < N; j++) {
			dp[1][j] = std::max(dp[0][j], dp[1][j - 1]) + a[1][j];
		}
		printf("%lld\n", dp[1][N - 1]);
		// for (int i = 0;i < 2; i++) {
		// 	for (int j = 0; j < N; j++) {
		// 		printf("%lld ", dp[i][j]);
		// 	}
		// 	printf("\n");
		// }
	}
	
	return 0;
}

/*

*/

Information

Submit By
Type
Submission
Problem
P1050 Game on 2d grid
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-08 05:43:42
Judged At
2024-11-11 03:30:45
Judged By
Score
0
Total Time
81ms
Peak Memory
6.645 MiB