Submission #1006263

# Submission time Handle Problem Language Result Execution time Memory
1006263 2024-06-23T15:46:22 Z kebine Bigger segments (IZhO19_segments) C++17
0 / 100
2 ms 14988 KB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define freeopen   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mod 1000000000
#define pb push_back
#define mk make_pair
#define ll long long
#define foor(x,vec) for(auto x:vec ){cout<<x<<" ";}
#define fi first
#define se second
#define MAXN 500069
#define lld long double
#define cha ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ffl fflush(stdout)
#define sst string
#define pii pair<ll,ll>
ll mvx[]={0,0,-1,1};
ll mvy[]={1,-1,0,0};

ll n;
ll a[MAXN],b[MAXN],ps[MAXN],dp[MAXN];
ll pos[MAXN],pos2[MAXN];
vector <ll> adj[MAXN];
map<ll,ll> mp;

void solve(){
    cin>>n;
    REP(i,1,n){
        cin>>a[i];
    }
    REP(i,1,n){
        ps[i]=ps[i-1]+a[i];
    }
    REP(i,1,n){
        if(ps[i]-ps[pos[i-1]]>=ps[pos[i-1]]-ps[pos2[i-1]]){
            dp[i]=dp[i-1]+1;
            pos2[i]=pos[i-1];
            pos[i]=i;
        }
        else{
            dp[i]=dp[i-1];
        }
    }
    cout<<dp[n]<<endl;
}

int main(){
    ll tc;
    tc=1;
//    cin>>tc;
    while(tc--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14936 KB Output is correct
2 Correct 2 ms 14940 KB Output is correct
3 Correct 2 ms 14940 KB Output is correct
4 Incorrect 2 ms 14988 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14936 KB Output is correct
2 Correct 2 ms 14940 KB Output is correct
3 Correct 2 ms 14940 KB Output is correct
4 Incorrect 2 ms 14988 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14936 KB Output is correct
2 Correct 2 ms 14940 KB Output is correct
3 Correct 2 ms 14940 KB Output is correct
4 Incorrect 2 ms 14988 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14936 KB Output is correct
2 Correct 2 ms 14940 KB Output is correct
3 Correct 2 ms 14940 KB Output is correct
4 Incorrect 2 ms 14988 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14936 KB Output is correct
2 Correct 2 ms 14940 KB Output is correct
3 Correct 2 ms 14940 KB Output is correct
4 Incorrect 2 ms 14988 KB Output isn't correct
5 Halted 0 ms 0 KB -