Submission #916464

#TimeUsernameProblemLanguageResultExecution timeMemory
91646412345678Triple Jump (JOI19_jumps)C++17
27 / 100
24 ms5724 KiB
#include <bits/stdc++.h> using namespace std; const int nx=5e5+5; int n, a[nx], mx[nx], res=-1e9, q, l, r; stack<int> s; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=1; i<=n; i++) cin>>a[i]; mx[n+1]=-1e9; for (int i=n; i>=1; i--) mx[i]=max(mx[i+1], a[i]); cin>>q>>l>>r; for (int i=1; i<=n; i++) { while (!s.empty()&&a[s.top()]<=a[i]) res=max(res, a[s.top()]+a[i]+mx[min(n+1, 2*i-s.top())]), s.pop(); if (!s.empty()) res=max(res, a[s.top()]+a[i]+mx[min(n+1, 2*i-s.top())]); s.push(i); } cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...