Submission #526631

# Submission time Handle Problem Language Result Execution time Memory
526631 2022-02-15T18:53:48 Z nitr0gen Divide and conquer (IZhO14_divide) C++14
0 / 100
1 ms 2636 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n, ans=0;
    cin >> n;
    ll x[100000], g[100000], d[100000];
    map<ll,ll> prefg, prefd;

    for(int i = 0; i < n; i++) {
        cin >> x[i] >> g[i] >> d[i];
        prefg[x[i]] = g[i];
        prefd[x[i]] = d[i];
        if(i) {
            prefg[x[i]] += prefg[x[i-1]];
        }
        if(i) {
            prefd[x[i]] += prefd[x[i-1]];
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = i; j < n; j++) {
            ll len = x[j] - x[i];
            ll power = prefd[x[j]];
            if(i) {
                power -= prefd[i-1];
            }
            if(power < len) continue;
            ll local_ans = prefg[x[j]];
            if(i) {
                local_ans -= prefg[x[i-1]];
            }
            ans = max(ans, local_ans);
        }
    }
    cout << ans << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Incorrect 1 ms 2636 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Incorrect 1 ms 2636 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Incorrect 1 ms 2636 KB Output isn't correct
3 Halted 0 ms 0 KB -