#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define xn '\n'
#define pb push_back
#define oo LONG_MAX
using namespace std;
typedef pair<ll,ll> i2;
typedef pair<ll,i2> i3;
typedef pair<i2,ll> i4;
const int N = 1e5+5;
const int M = 1e3+5;
const ll mo = 1e9+7;
ll n,m;
ll l,r;
ll a[N];
ll c[N];
ll d[N];
ll res;
stack <ll> s;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (long i=1; i<=n; i++) cin >> a[i];
for (long i=n; i>=1; i--) c[i] = max(c[i+1],a[i]);
cin >> m >> l >> r;
for (long i=1; i<=n; i++){
ll j1 = 0;
while (!s.empty() && a[i] > a[s.top()]) s.pop();
if (!s.empty()) j1 = s.top();
res = max(res,a[j1]+a[i]+c[i+i-j1]);
s.push(i);
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
5956 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |