제출 #545417

#제출 시각아이디문제언어결과실행 시간메모리
545417krit3379Bigger segments (IZhO19_segments)C++17
0 / 100
0 ms212 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 500005 long long a[N]; pair<int,int> dp[N]; int main(){ int n,i; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%lld",&a[i]),a[i]+=a[i-1]; dp[0]={1,0}; for(i=1;i<=n;i++){ dp[i]=max(dp[i],dp[i-1]); int pos=lower_bound(a+1,a+n+1,2*a[i]-dp[i].second)-a; dp[pos]=max(dp[pos],{dp[i].first+1,a[pos]-a[i]}); } printf("%d",dp[n].first); return 0; }

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

segments.cpp: In function 'int main()':
segments.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
segments.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(i=1;i<=n;i++)scanf("%lld",&a[i]),a[i]+=a[i-1];
      |                      ~~~~~^~~~~~~~~~~~~~
#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...