제출 #526327

#제출 시각아이디문제언어결과실행 시간메모리
526327CursedCodeBigger segments (IZhO19_segments)C++14
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> #include<cstdio> #include<algorithm> using namespace std; long long S[501000]; int w[501000], n, D[501000], P[501000], res; int main(){ int i; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&w[i]); S[i]=S[i-1]+w[i]; } for(i=1;i<=n;i++){ P[i]=max(P[i],P[i-1]); D[i]=D[P[i]]+1; long long s = S[i]+S[i]-S[P[i]]; int pv = lower_bound(S+1,S+n+1,s)-S; P[pv]=max(P[pv],i); } for(i=1;i<=n;i++){ cout << P[i] << endl; } printf("%d\n",D[n]); }

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

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