# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1103922 |
2024-10-22T09:10:09 Z |
ntmin |
Triple Jump (JOI19_jumps) |
C++14 |
|
4000 ms |
138280 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define ON(a, b) (a >> b & 1)
#define all(x) x.begin(), x.end()
template<typename T> bool maximise(T &a, T b){if(a < b){a = b; return 1;} return 0;}
template<typename T> bool minimise(T &a, T b){if(a > b){a = b; return 1;} return 0;}
const int N = 5e5 + 1;
int a[N], st[19][N], n, q;
const int M = 5010;
int maxx[M][M];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> a[i];
st[0][i] = a[i];
}
for(int k = 1; k < 19; ++k){
for(int i = 1; i + (1 << k) - 1 <= n; ++i){
st[k][i] = max(st[k - 1][i], st[k - 1][i + (1 << (k - 1))]);
}
}
auto getmax = [&](int l, int r) -> int {
int k = __lg(r - l + 1);
return max(st[k][l], st[k][r - (1 << k) + 1]);
};
for(int i = 1; i <= n; ++i){
for(int j = i + 2; j <= n; ++j){
maxx[i][j] = a[i] + a[j] + getmax(i + 1, i + ((j - i + 1) / 2 - ((j - i + 1) % 2 == 0)));
}
}
for(int i = n; i >= 1; --i){
for(int j = i + 1; j <= n; ++j){
maximise(maxx[i][j], max({maxx[i + 1][j], maxx[i][j - 1], maxx[i + 1][j - 1]}));
}
}
int q; cin >> q;
while(q--){
int l, r; cin >> l >> r;
cout << maxx[l][r] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
2 ms |
18768 KB |
Output is correct |
3 |
Correct |
3 ms |
18768 KB |
Output is correct |
4 |
Correct |
2 ms |
18768 KB |
Output is correct |
5 |
Correct |
3 ms |
18768 KB |
Output is correct |
6 |
Correct |
2 ms |
18908 KB |
Output is correct |
7 |
Correct |
2 ms |
18768 KB |
Output is correct |
8 |
Correct |
3 ms |
18768 KB |
Output is correct |
9 |
Correct |
2 ms |
18768 KB |
Output is correct |
10 |
Correct |
2 ms |
18768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
2 ms |
18768 KB |
Output is correct |
3 |
Correct |
3 ms |
18768 KB |
Output is correct |
4 |
Correct |
2 ms |
18768 KB |
Output is correct |
5 |
Correct |
3 ms |
18768 KB |
Output is correct |
6 |
Correct |
2 ms |
18908 KB |
Output is correct |
7 |
Correct |
2 ms |
18768 KB |
Output is correct |
8 |
Correct |
3 ms |
18768 KB |
Output is correct |
9 |
Correct |
2 ms |
18768 KB |
Output is correct |
10 |
Correct |
2 ms |
18768 KB |
Output is correct |
11 |
Correct |
229 ms |
135488 KB |
Output is correct |
12 |
Correct |
233 ms |
135444 KB |
Output is correct |
13 |
Correct |
263 ms |
135240 KB |
Output is correct |
14 |
Correct |
239 ms |
133704 KB |
Output is correct |
15 |
Correct |
251 ms |
135496 KB |
Output is correct |
16 |
Correct |
241 ms |
121952 KB |
Output is correct |
17 |
Correct |
263 ms |
106568 KB |
Output is correct |
18 |
Correct |
217 ms |
125932 KB |
Output is correct |
19 |
Correct |
211 ms |
127816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4058 ms |
138280 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
2 ms |
18768 KB |
Output is correct |
3 |
Correct |
3 ms |
18768 KB |
Output is correct |
4 |
Correct |
2 ms |
18768 KB |
Output is correct |
5 |
Correct |
3 ms |
18768 KB |
Output is correct |
6 |
Correct |
2 ms |
18908 KB |
Output is correct |
7 |
Correct |
2 ms |
18768 KB |
Output is correct |
8 |
Correct |
3 ms |
18768 KB |
Output is correct |
9 |
Correct |
2 ms |
18768 KB |
Output is correct |
10 |
Correct |
2 ms |
18768 KB |
Output is correct |
11 |
Correct |
229 ms |
135488 KB |
Output is correct |
12 |
Correct |
233 ms |
135444 KB |
Output is correct |
13 |
Correct |
263 ms |
135240 KB |
Output is correct |
14 |
Correct |
239 ms |
133704 KB |
Output is correct |
15 |
Correct |
251 ms |
135496 KB |
Output is correct |
16 |
Correct |
241 ms |
121952 KB |
Output is correct |
17 |
Correct |
263 ms |
106568 KB |
Output is correct |
18 |
Correct |
217 ms |
125932 KB |
Output is correct |
19 |
Correct |
211 ms |
127816 KB |
Output is correct |
20 |
Execution timed out |
4058 ms |
138280 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |