Submission #535663

# Submission time Handle Problem Language Result Execution time Memory
535663 2022-03-10T20:53:24 Z MOUF_MAHMALAT Cigle (COI21_cigle) C++14
9 / 100
52 ms 1284 KB
#include<bits/stdc++.h>
#define all(s) s.begin(),s.end()
#define F first
#define S second
using namespace std;
typedef int ll;
ll n,a[5009],dp[509][509],p[5009],ans;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        cin>>a[i];
        p[i]=p[i-1]+a[i];
    }
    for(ll i=2; i<=n; i++)
    {
        for(ll j=i; j<=n; j++)
        {
            ll sum=0,l=i;
            dp[i][j]=dp[i-1][i-1];
            for(ll k=i-2; k; k--)
            {
                while(p[l]-p[i-1]<p[i-1]-p[k]&&l<j-1)
                    l++;
                if(p[l]-p[i-1]==p[i-1]-p[k]&&p[l]-p[i-1])
                    sum++;
                dp[i][j]=max(dp[i][j],dp[k][i-1]+sum);
            }
        }
    }
    for(ll i=1; i<=n; i++)
        ans=max(ans,dp[i][n]);
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Incorrect 1 ms 468 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1280 KB Output is correct
2 Correct 45 ms 1272 KB Output is correct
3 Correct 51 ms 1284 KB Output is correct
4 Correct 47 ms 1240 KB Output is correct
5 Correct 52 ms 1272 KB Output is correct
6 Incorrect 47 ms 1212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Incorrect 1 ms 468 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Incorrect 1 ms 468 KB Output isn't correct
15 Halted 0 ms 0 KB -