# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
420474 | Pyqe | Cigle (COI21_cigle) | C++14 | 540 ms | 235308 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;
const long long inf=1e18;
long long n,ps[5069],px[2][5069][5069],fh[5069],fq[5069];
int main()
{
long long i,j,k,z=0;
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
scanf("%lld",ps+i);
ps[i]+=ps[i-1];
}
for(i=1;i<=n;i++)
{
px[0][i][0]=-inf;
px[0][i][1]=-inf;
px[1][i][1]=-inf;
for(j=0;j<i;j++)
{
k=max(px[0][j][fh[j]]+fq[j],px[1][j][fh[j]+1]);
z=max(z,k);
px[0][i][j+2]=max(px[0][i][j+1],k);
px[1][i][j+2]=k;
for(;fh[j]&&ps[j]-ps[fh[j]-1]<=ps[i]-ps[j];fh[j]--)
{
fq[j]+=ps[j]-ps[fh[j]-1]==ps[i]-ps[j];
px[1][j][fh[j]]=max(px[1][j][fh[j]+1],px[1][j][fh[j]]+fq[j]);
}
}
px[1][i][i+2]=-inf;
fh[i]=i+1;
}
printf("%lld\n",z);
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |