#include "bits/stdc++.h"
using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
#define uwu ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize("Ofast")
const int INF = 1e9 + 7;
const long long INF2 = 1e17;
int main(void) {
uwu
int n; cin >> n;
vector <long long> v(n);
ffor(n) cin >> v[i];
vector <tuple <int, int, int, long long>> jumps;
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
for(int delta = j - i, k = j + delta; k < n; k++) {
jumps.push_back(tuple(i, j, k, v[i] + v[j] + v[k]));
}
}
}
int q; cin >> q;
ffor(q) {
int a, b; cin >> a >> b;
a--; b--;
long long current = 0;
for(int j = 0; j < (int)jumps.size(); j++) {
if (get<0>(jumps[j]) >= a && get<2>(jumps[j]) <= b) {
current = max(current, get<3>(jumps[j]));
}
}
cout << current << '\n';
}
}
/*
C:\Users\kenne\OneDrive\Desktop\competitive_programming\main.cpp
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
3524 KB |
Output is correct |
3 |
Correct |
13 ms |
3524 KB |
Output is correct |
4 |
Correct |
13 ms |
3524 KB |
Output is correct |
5 |
Correct |
14 ms |
3524 KB |
Output is correct |
6 |
Correct |
13 ms |
3524 KB |
Output is correct |
7 |
Correct |
13 ms |
3524 KB |
Output is correct |
8 |
Correct |
14 ms |
3536 KB |
Output is correct |
9 |
Correct |
13 ms |
3524 KB |
Output is correct |
10 |
Correct |
13 ms |
3524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
3524 KB |
Output is correct |
3 |
Correct |
13 ms |
3524 KB |
Output is correct |
4 |
Correct |
13 ms |
3524 KB |
Output is correct |
5 |
Correct |
14 ms |
3524 KB |
Output is correct |
6 |
Correct |
13 ms |
3524 KB |
Output is correct |
7 |
Correct |
13 ms |
3524 KB |
Output is correct |
8 |
Correct |
14 ms |
3536 KB |
Output is correct |
9 |
Correct |
13 ms |
3524 KB |
Output is correct |
10 |
Correct |
13 ms |
3524 KB |
Output is correct |
11 |
Runtime error |
471 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
518 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
3524 KB |
Output is correct |
3 |
Correct |
13 ms |
3524 KB |
Output is correct |
4 |
Correct |
13 ms |
3524 KB |
Output is correct |
5 |
Correct |
14 ms |
3524 KB |
Output is correct |
6 |
Correct |
13 ms |
3524 KB |
Output is correct |
7 |
Correct |
13 ms |
3524 KB |
Output is correct |
8 |
Correct |
14 ms |
3536 KB |
Output is correct |
9 |
Correct |
13 ms |
3524 KB |
Output is correct |
10 |
Correct |
13 ms |
3524 KB |
Output is correct |
11 |
Runtime error |
471 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |