Submission #703307

#TimeUsernameProblemLanguageResultExecution timeMemory
703307fdnfksdBigger segments (IZhO19_segments)C++14
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<int,int> #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=5e5+10; const ll inf=1e18; const ll mod=1e9+7; ll a[maxN],n; ll get(ll x) { ll sum=0; for(int i=1;i<=x;i++) { sum+=a[i]; } ll cnt=1; for(int j=x+1;j<=n;j++) { ll k=j; ll ss=0; while(k<=n&&ss<sum) { ss+=a[k]; k++; } j=k-1; if(ss>=sum) cnt++,sum=ss; } return cnt; } void solve() { cin >> n; for(int i=1;i<=n;i++) cin >> a[i]; ll ans=1; for(int i=1;i<=n;i++) ans=max(ans,get(i)); cout << ans; } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }
#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...