Submission #1006245

# Submission time Handle Problem Language Result Execution time Memory
1006245 2024-06-23T15:17:40 Z christinelynn Bigger segments (IZhO19_segments) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
bool ckmin(int& a, int b){return b < a ? a = b, 1 : 0;}
bool ckmax(int& a, int b){return b > a ? a = b, 1 : 0;}
const int N = 2e5 + 5, mod = 1e9 + 7;

signed main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n; cin >> n;
    vector<int> v(n + 2), dp(n + 1), pos(n + 1), p(n + 2);
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        p[i] = p[i - 1] + v[i];
    }
    p[n + 1] = p[n] + 1e18;
    for(int i = 1; i <= n; i++) {
        pos[i] = max(pos[i], pos[i - 1]);
        dp[i] = dp[pos[i]] + 1;
        int it = lower_bound(p.begin() + 1, p.begin() + n + 1, 2 * p[i] - p[pos[i]]) - p.begin();
        pos[it] = i;
    }
    cout << dp[n] << endl;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -