# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91084 | Hideo | Divide and conquer (IZhO14_divide) | C++14 | 1076 ms | 2916 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
ll x[N], g[N], d[N];
int n;
ll mx, pre[N], prg[N];
main(){
cin >> n;
for (int i = 1; i <= n; i++){
scanf("%lld%lld%lld", &x[i], &g[i], &d[i]);
mx = max(g[i], mx);
prg[i] = prg[i - 1] + g[i];
pre[i] = pre[i - 1] + d[i];
}
for (int i = 1; i <= n; i++){
for (int j = i + 1; j <= n; j++){
if (pre[j] - pre[i - 1] >= x[j] - x[i]){
mx = max (prg[j] - prg[i - 1], mx);
}
}
}
cout << mx;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |