Submission #1013059

# Submission time Handle Problem Language Result Execution time Memory
1013059 2024-07-03T06:43:04 Z abushbandit_ Triple Jump (JOI19_jumps) C++17
5 / 100
4000 ms 524288 KB
/*
 
author : abushbandit
contest : ---
 
*/
 
#include "bits/stdc++.h"

using namespace std;

#define all(x) x.begin(),x.end()
#define pb push_back

void solve() {
	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	int mx[n][n] {};
	for(int i = 0;i < n;i++){
		mx[i][i] = a[i];
		for(int j = i + 1;j < n;j++){
			mx[i][j] = max(mx[i][j - 1],a[j]); 
		}
	}
	int q;
	cin >> q;
	for(int i = 0;i < q;i++){
		int l,r;
		cin >> l >> r;
		l--;
		r--;
		int ans = 0;
		for(int k = l;k <= r;k++){
			for(int j = k + 1;j <= r;j++){
				if(j + j - k > r) break;
				int res = a[k] + a[j];
				res += mx[j + (j - k)][r];
				ans = max(ans,res);
			}
		}
		cout << ans << "\n";
	}


	
}

signed main() {
	
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	
	int t = 1;
	//~ cin >> t;
	while(t--){
		solve();
	}
 
}

	
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 4018 ms 98536 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 254 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 4018 ms 98536 KB Time limit exceeded
12 Halted 0 ms 0 KB -