# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007966 | Rolo678 | Triple Jump (JOI19_jumps) | C++14 | 4072 ms | 15516 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int>a(n+1);
for(int i = 1;i<=n;i++)
{
cin >> a[i];
}
vector<vector<pair<int,int>>>p(n+1);
for(int i = 1;i<=n;i++)
{
int mx = 0;
for(int j = i+1;j<=n;j++)
{
if(a[j] >= mx )
{
p[i].push_back({a[j],j});
}
mx = max(a[j],mx);
}
}
int q;
cin >> q;
while(q--)
{
int l,r;
cin >> l >> r;
long long ans = 0;
int a1,b,c;
for(int i = l;i<=r-2;i++)
{
for(auto j :p[i])
{
if(j.second > r-1)
{
continue;
}
for(int k = 2*(j.second) - i;k <= r;k++)
{
if(k<1 || !(k -j.second >= j.second - i )|| k <=j.second || k<=i)
{
continue;
}
ans = max(ans,(long long)(a[i]+j.first+a[k]));
}
}
}
cout << ans <<'\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |