Submission #295331

# Submission time Handle Problem Language Result Execution time Memory
295331 2020-09-09T15:38:36 Z erd1 Triple Jump (JOI19_jumps) C++14
19 / 100
2128 ms 202352 KB
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef int64_t lld;
typedef pair<int, int> pii;

array<array<int, 5000>, 5000> ans;
vector<int> v;

signed main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    v.pb(a);
  }
  for(int i = 0; i < n; i++)
    for(int j = i+2, mx = -1; j < n; j++) {
      if((i+j)%2 == 0) mx = max(mx, v[i+j>>1]);
      ans[i][j] = v[i]+v[j]+mx;
    }
  for(int l = 3; l < n; l++)
    for(int i = 0, j = l; j < n; i++, j++)
      ans[i][j] = max({ans[i][j], ans[i+1][j], ans[i][j-1]});
  int q;
  cin >> q;
  while(q--){
    int a, b; cin >> a >> b; cout << ans[a-1][b-1] << endl;
  }
}

Compilation message

jumps.cpp: In function 'int main()':
jumps.cpp:22:40: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   22 |       if((i+j)%2 == 0) mx = max(mx, v[i+j>>1]);
      |                                       ~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 1 ms 768 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 1 ms 768 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1883 ms 77164 KB Output is correct
12 Correct 1918 ms 77132 KB Output is correct
13 Correct 1935 ms 76980 KB Output is correct
14 Correct 2128 ms 77040 KB Output is correct
15 Correct 2068 ms 76996 KB Output is correct
16 Correct 1947 ms 76232 KB Output is correct
17 Correct 1923 ms 76368 KB Output is correct
18 Correct 1930 ms 76352 KB Output is correct
19 Correct 1916 ms 76908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1881 ms 202352 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 1 ms 768 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1883 ms 77164 KB Output is correct
12 Correct 1918 ms 77132 KB Output is correct
13 Correct 1935 ms 76980 KB Output is correct
14 Correct 2128 ms 77040 KB Output is correct
15 Correct 2068 ms 76996 KB Output is correct
16 Correct 1947 ms 76232 KB Output is correct
17 Correct 1923 ms 76368 KB Output is correct
18 Correct 1930 ms 76352 KB Output is correct
19 Correct 1916 ms 76908 KB Output is correct
20 Runtime error 1881 ms 202352 KB Execution killed with signal 11
21 Halted 0 ms 0 KB -