#include <bits/stdc++.h>
using namespace std;
const int N = (int) 5e5 + 7;
const int INF = (int) 1e9 + 7;
int n;
int q;
int a[N];
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
//freopen ("input", "r", stdin);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
cin >> q;
for (int iq = 1; iq <= q; iq++) {
int l, r, best = 0;
cin >> l >> r;
for (int i = l; i <= r; i++) {
for (int j = i + 1; j <= r; j++) {
for (int k = j + 1; k <= r; k++) {
if (j - i <= k - j) {
best = max(best, a[i] + a[j] + a[k]);
}
}
}
}
cout << best << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
324 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
324 KB |
Output is correct |
7 |
Correct |
3 ms |
328 KB |
Output is correct |
8 |
Correct |
3 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
208 KB |
Output is correct |
10 |
Correct |
3 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
324 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
324 KB |
Output is correct |
7 |
Correct |
3 ms |
328 KB |
Output is correct |
8 |
Correct |
3 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
208 KB |
Output is correct |
10 |
Correct |
3 ms |
328 KB |
Output is correct |
11 |
Execution timed out |
4051 ms |
440 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4050 ms |
2764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
324 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
324 KB |
Output is correct |
7 |
Correct |
3 ms |
328 KB |
Output is correct |
8 |
Correct |
3 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
208 KB |
Output is correct |
10 |
Correct |
3 ms |
328 KB |
Output is correct |
11 |
Execution timed out |
4051 ms |
440 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |