Submission #330689

# Submission time Handle Problem Language Result Execution time Memory
330689 2020-11-26T09:13:03 Z vitkishloh228 Bigger segments (IZhO19_segments) C++14
0 / 100
0 ms 364 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];
    }
    vector<int> dp(n + 1), bb(n + 1);
    for (int i = 1; i < n; ++i) {
        bb[i] = max(bb[i], bb[i - 1]);
        dp[i] = dp[bb[i]] + 1;
        int x = pr[i] - pr[bb[i]];
        int ini = i + 1, fim = n, meio, best = 0;
        while (ini <= fim) {
            meio = (ini + fim) >> 1;
            if (pr[meio] - pr[i] >= x) {
                fim = meio - 1;
                best = meio;
            }
            else
                ini = meio + 1;
        }
        bb[best] = i;
    }
    cout << dp[n];
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -