Submission #941536

# Submission time Handle Problem Language Result Execution time Memory
941536 2024-03-09T06:01:33 Z LCJLY Triple Jump (JOI19_jumps) C++14
0 / 100
18 ms 6844 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long 
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
typedef pair<int,pii>pi2;

void solve(){
	int n;
	cin >> n;
	int arr[n+1];
	for(int x=1;x<=n;x++){
		cin >> arr[x];
	}
	
	int prefix[n+5];
	int suffix[n+5];
	memset(prefix,0,sizeof(prefix));
	memset(suffix,0,sizeof(suffix));
	for(int x=1;x<=n;x++){
		prefix[x]=max(prefix[x-1]+arr[x],prefix[x]);
	}
	for(int x=n;x>=1;x--){
		suffix[x]=max(suffix[x-1]+arr[x],suffix[x]);
	}
	int q;
	cin >> q;
	int l,r;
	cin >> l >> r;
	int a=1;
	int b=2;
	int best=0;
	for(int x=1;x<=n;x++){
		if(b>n) break;
		best=max(best,prefix[a]+suffix[b]);
		a++;
		b+=2;
	}
	cout << best;
}	

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 6844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -