#include <bits/stdc++.h>
using namespace std;
const int nx=2e5+5;
int n, q, a[nx], dpl[nx], dpr[nx], res;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>a[i], dpl[i]=max(dpl[i-1], a[i]);
for (int i=n; i>=1; i--) dpr[i]=max(dpr[i+1], a[i]);
for (int i=2; i<n; i++) if (dpl[i-1]+dpr[i+1]>=2*a[i]) res=max(res, dpl[i-1]+dpr[i+1]+a[i]);
cin>>n>>n>>n;
cout<<res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |