Submission #330687

# Submission time Handle Problem Language Result Execution time Memory
330687 2020-11-26T09:03:57 Z vitkishloh228 Bigger segments (IZhO19_segments) C++14
0 / 100
1 ms 384 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
int32_t main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> pr(n + 1);
    for (int i = 0; i < n; ++i) {
        pr[i + 1] = pr[i] + a[i];
    }
    int x = a[0];
    int it = 1;
    int ans = 1;
    while (true) {
       // cout << x << endl;
        if (it >= n - 1) break;
        vector<int>::iterator it1 = pr.begin() + it + 1;
        int pos = lower_bound(it1, pr.end(), x + pr[it]) - pr.begin();
        {
            ans++;
            if (x < pr[pos] - pr[it]) {
                ans++;
                x = pr[pos] - pr[it];
                break;
            }
            it = pos;
        }
        
        //cout << it << endl;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -