# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
543859 |
2022-03-31T14:00:29 Z |
levladiator |
Cigle (COI21_cigle) |
C++14 |
|
119 ms |
2820 KB |
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define EPSILON 0.000001
#define CH (*s-'a')
using namespace std;
const ll NMAX = 5e3 + 5, INF = 1e18, MOD = 1e9 + 7, MMAX = 1e2 + 5, inf = 1e9;
ifstream fin("sufle.in");
ofstream fout("sufle.out");
int N,ans;
int v[NMAX],best[NMAX][NMAX],S[NMAX];
int main()
{
cin.tie ( 0 )->sync_with_stdio ( 0 );
cin.tie ( NULL );
cout.tie ( NULL );
cin>>N;
for(int i=1;i<=N;i++)
{
cin>>v[i];
S[i]=S[i-1]+v[i];
}
for(int i=2;i<=N;i++)
{
for(int j=i;j>=1;j--)
{
int ind=j-1;
int layer=0;
int sum=0;
for(int k=j;k<=i;k++)
{
sum+=v[k];
while(sum>layer&&ind>0)
{
layer+=v[ind];
ind--;
}
if(sum==layer&&k<i)best[i][j]++;
}
ind++;
if(layer>sum)
{
if(sum-v[i]<layer-v[ind])
{
layer-=v[ind];
ind++;
}
}
else if(layer<sum)
{
if(sum-v[i]>=layer)
{
if(j>1)best[i][j]=-1;
}
}
int add=0;
for(int k=ind;k>=1;k--)
{
add=max(add,best[j-1][k]);
}
best[i][j]+=add;
if(add==-1)best[i][j]=-1;
ans=max(ans,best[i][j]);
//cout<<best[i][j]<<' ';
}
//cout<<'\n';
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
2820 KB |
Output is correct |
2 |
Correct |
57 ms |
2704 KB |
Output is correct |
3 |
Correct |
56 ms |
2816 KB |
Output is correct |
4 |
Correct |
71 ms |
2776 KB |
Output is correct |
5 |
Correct |
64 ms |
2708 KB |
Output is correct |
6 |
Incorrect |
119 ms |
2700 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |