제출 #376950

#제출 시각아이디문제언어결과실행 시간메모리
376950joelauBigger segments (IZhO19_segments)C++14
0 / 100
1 ms492 KiB
#include <bits/stdc++.h> using namespace std; int N,ans[500000]; long long A[500001], sz[500000]; int main() { scanf("%d", &N); A[0] = 0; for (int i = 1; i <= N; ++i) { scanf("%lld", &A[i]); A[i] += A[i-1]; } ans[0] = 1, sz[0] = A[1]; for (int i = 1, j = 0; i < N; ++i) { while (j < i && sz[j] <= A[i+1] - A[j+1]) j++; if (j == 0) ans[i] = 1, sz[i] = A[i+1]; else ans[i] = ans[j-1]+1, sz[i] = A[i+1] - A[j]; } printf("%d", ans[N-1]); return 0; }

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

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