# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
163898 | 2019-11-16T06:23:04 Z | ho94949 | Triple Jump (JOI19_jumps) | C++17 | 100 ms | 9572 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 524288; int N; int A[MAXN]; int nv[MAXN]; int idx[2*MAXN]; int getv(int a, int b) { a += MAXN; b += MAXN; int ans = 0; while(a<=b) { if(a%2==1) ans = max(ans, idx[a++]); if(b%2==0) ans = max(ans, idx[b--]); a/=2; b/=2; } return ans; } void setv(int a, int v) { idx[a+=MAXN] = v; while((a=a/2)) idx[a] = max(idx[2*a], idx[2*a+1]); } int solve() { A[N] = (int)1e8+1; stack<int> S; for(int i=0; i<=N; ++i) { setv(i, A[i]); while(!S.empty() && A[S.top()] < A[i]) { nv[S.top()] = i; S.pop(); } S.push(i); } vector<pair<int, int> > ab; for(int a=0; a<N-1; ++a) { int b = a+1; ab.emplace_back(a, b); while(nv[b] != N && A[b]<A[a]) { b = nv[b]; ab.emplace_back(a, b); } } int ret = 0; for(auto [a, b]: ab) { int cind = 2*b-a; int ans = A[a] + A[b] + getv(cind, N-1); ret = max(ret, ans); } return ret; } int main() { scanf("%d", &N); for(int i=0; i<N; ++i) scanf("%d", A+i); int Q; scanf("%d", &Q); assert(Q==1); int L, R; scanf("%d%d", &L, &R); assert(L==1&&R==N); printf("%d\n", solve()); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 100 ms | 9572 KB | Output is correct |
2 | Correct | 69 ms | 7528 KB | Output is correct |
3 | Correct | 70 ms | 7944 KB | Output is correct |
4 | Correct | 99 ms | 9436 KB | Output is correct |
5 | Correct | 100 ms | 9568 KB | Output is correct |
6 | Correct | 94 ms | 8904 KB | Output is correct |
7 | Correct | 92 ms | 8680 KB | Output is correct |
8 | Correct | 90 ms | 8804 KB | Output is correct |
9 | Correct | 95 ms | 9092 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |