제출 #172700

#제출 시각아이디문제언어결과실행 시간메모리
172700LinusTorvaldsFanBigger segments (IZhO19_segments)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin>>n; vector<int>a(n); for(int i=0;i<n;i++){ cin>>a[i]; } int ind=0; int ans=0; ll p_sum=0; while(ind<n){ ll sum=0; ans++; int best_ind=-1; int best_pos=n+1; ll best_sum=0; for(int i=ind;i<n;i++){ sum+=a[i]; ll cur=0; if(sum<p_sum)continue; for(int j=i+1;j<n;j++){ cur+=a[j]; if(cur>=sum){ if(j<=best_pos){ best_pos=j; best_ind=i; best_sum=sum; } break; } } } if(best_ind==-1){ break; } //cout<<best_ind<<endl; ind=best_ind+1; p_sum=best_sum; } cout<<ans; return 0; }
#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...