제출 #526571

#제출 시각아이디문제언어결과실행 시간메모리
526571BelguteiBigger segments (IZhO19_segments)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); const int N = 500005; ll n,a[N]; ll ans; ll cur,pre,pre_ehlel,pre_end; int main(){ IOS cin>>n; for(int i=1; i<=n; i++){ cin>>a[i]; } cur=0; pre=a[1]; pre_end=1; ans=1; int l=2; while(l<=n){ cur+=a[l]; if(cur>=pre){ for(int i=pre_end+1; i<=l; i++){ if(cur-a[i]>=pre+a[i]){ cur-=a[i]; pre+=a[i]; } else break; } pre_end=l; pre=cur; ans++; cur=0; } l++; } cout<<ans; }
#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...