답안 #543851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
543851 2022-03-31T13:49:55 Z levladiator Cigle (COI21_cigle) C++14
0 / 100
112 ms 1304 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 = 5e2 + 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+1])
                {
                    ind++;
                    layer-=v[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<<ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 1208 KB Output is correct
2 Correct 67 ms 1304 KB Output is correct
3 Correct 59 ms 1232 KB Output is correct
4 Correct 56 ms 1216 KB Output is correct
5 Correct 68 ms 1296 KB Output is correct
6 Incorrect 112 ms 1272 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -