Submission #1098333

# Submission time Handle Problem Language Result Execution time Memory
1098333 2024-10-09T10:01:34 Z ezzzay Bigger segments (IZhO19_segments) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ff first
#define ss second
#define pb push_back
const int N=3e6+5;
int a[N];
int par[N];
int dp[N];
signed main(){
    int n;
    cin>>n;
    vector<int>ps(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ps[i]=ps[i-1]+a[i];
    }
    for(int i=1;i<=n;i++){
        par[i]=max(par[i],par[i-1]);
        
        dp[i]=dp[par[i]]+1;
        auto it=lower_bound(ps.begin(),ps.end(),ps[i*2]-ps[par[i-1]]);
        int j=it-ps.begin();
        par[j]=i;
    }
    
    cout<<dp[n];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -