Submission #526570

# Submission time Handle Problem Language Result Execution time Memory
526570 2022-02-15T09:23:41 Z Belgutei Bigger segments (IZhO19_segments) C++17
0 / 100
1 ms 304 KB
#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-1;
            pre=cur;
            ans++;
            cur=0;
            if(l==n){
                cout<<ans;
                return 0;
            }
        }
        l++;
    }
    cout<<ans;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Incorrect 1 ms 224 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Incorrect 1 ms 224 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Incorrect 1 ms 224 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Incorrect 1 ms 224 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Incorrect 1 ms 224 KB Output isn't correct
10 Halted 0 ms 0 KB -