Submission #782558

#TimeUsernameProblemLanguageResultExecution timeMemory
782558ZHIRDILBILDIZBigger segments (IZhO19_segments)C++14
0 / 100
1 ms324 KiB
#include<bits/stdc++.h>
#define ll long long
using namespace std ;
signed main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
    ll n, ans = 0 ;
    cin >> n ;
    ll a[n + 1] ;
    for(ll i = 1 ; i <= n ; i++)
        cin >> a[i] ;
    for(ll i = 1 ; i <= n ; i++)
    {
        ll kol = 1, ls = 0, now = 0 ;
        for(ll j = 1 ; j <= i ; j++)
            ls += a[j] ;
        for(ll j = i + 1 ; j <= n ; j++)
            if(now < ls)
                now += a[j] ;
            else
            {
                ls = now ;
                now = a[j] ;
                kol++ ;
            }
        if(now >= ls)kol++ ;
        ans = max(ans, kol) ;
    }
    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...