답안 #1013055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013055 2024-07-03T06:41:59 Z huyboy 3단 점프 (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();
	}
 
}

	
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 4032 ms 98128 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 229 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 4032 ms 98128 KB Time limit exceeded
12 Halted 0 ms 0 KB -