Submission #812257

# Submission time Handle Problem Language Result Execution time Memory
812257 2023-08-07T08:02:34 Z vjudge1 Triple Jump (JOI19_jumps) C++17
19 / 100
529 ms 241268 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 5e3 + 10;
int n;
ll a[N];
ll dp[N][N], mx[N][N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) 
        cin >> a[i];
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j++) {
            mx[i][j] = max(mx[i][j - 1], a[j]);
        }
    }
    for(int len = 2; len <= n; len++) {
        for(int l = 1; l <= n - len + 1; l++) {
            int r = l + len - 1;
            dp[l][r] = max({dp[l][r - 1], dp[l + 1][r], a[l] + a[r] + mx[l + 1][(l + r) / 2]});
        }
    }
    int q;
    cin >> q;
    while(q--) {
        int l, r;
        cin >> l >> r;
        cout << dp[l][r] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1220 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1220 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 527 ms 241192 KB Output is correct
12 Correct 511 ms 241100 KB Output is correct
13 Correct 513 ms 241152 KB Output is correct
14 Correct 514 ms 241268 KB Output is correct
15 Correct 520 ms 241128 KB Output is correct
16 Correct 521 ms 240608 KB Output is correct
17 Correct 521 ms 240552 KB Output is correct
18 Correct 529 ms 240472 KB Output is correct
19 Correct 519 ms 241112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 196 ms 848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1220 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 527 ms 241192 KB Output is correct
12 Correct 511 ms 241100 KB Output is correct
13 Correct 513 ms 241152 KB Output is correct
14 Correct 514 ms 241268 KB Output is correct
15 Correct 520 ms 241128 KB Output is correct
16 Correct 521 ms 240608 KB Output is correct
17 Correct 521 ms 240552 KB Output is correct
18 Correct 529 ms 240472 KB Output is correct
19 Correct 519 ms 241112 KB Output is correct
20 Runtime error 196 ms 848 KB Execution killed with signal 11
21 Halted 0 ms 0 KB -