제출 #770639

#제출 시각아이디문제언어결과실행 시간메모리
770639AmylopectinBigger segments (IZhO19_segments)C++14
0 / 100
1 ms212 KiB
#include <stdio.h>
#include <iostream>

using namespace std;
const int mxn = 1e6 + 10;
int a[mxn] = {};
int main()
{
    int i,j,n,m,cou = 1,be,csu,lo,dif;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&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];
            }
            be = csu;
            cou ++;
            csu = 0;
        }
    }
    printf("%d\n",cou);
}

컴파일 시 표준 에러 (stderr) 메시지

segments.cpp: In function 'int main()':
segments.cpp:9:15: warning: unused variable 'm' [-Wunused-variable]
    9 |     int 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("%d",&n);
      |     ~~~~~^~~~~~~~~
segments.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&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...