Submission #770648

#TimeUsernameProblemLanguageResultExecution timeMemory
770648AmylopectinBigger segments (IZhO19_segments)C++14
0 / 100
1 ms212 KiB
#include <stdio.h>
#include <iostream>

using namespace std;
const long long mxn = 1e6 + 10;
long long a[mxn] = {};
int main()
{
    long long i,j,n,m,cou = 1,be,csu,lo,dif;
    scanf("%lld",&n);
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    be = a[0];
    csu = 0;
    lo = 1;
    for(i=1; i<n; i++)
    {
        csu += a[i];
        if(csu >= be)
        {
            dif = csu - be;
            for(j=lo; j<i; j++)
            {
                if(a[j] * 2 > dif)
                {
                    break;
                }
                dif -= a[j] * 2;
                csu -= a[j];
            }
            lo = i+1;
            be = csu;
            cou ++;
            csu = 0;
        }
    }
    printf("%lld\n",cou);
}

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:9:21: warning: unused variable 'm' [-Wunused-variable]
    9 |     long long i,j,n,m,cou = 1,be,csu,lo,dif;
      |                     ^
segments.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
segments.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...