# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166385 | abil | Divide and conquer (IZhO14_divide) | C++14 | 1070 ms | 2284 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>
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
#define int long long
using namespace std;
const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (1e15 + 9);
int x[N], g[N], c[N], pr[N], prg[N];
main()
{
int n;
scanf("%lld", &n);
for(int i = 1;i <= n; i++){
scanf("%lld%lld%lld", &x[i], &g[i], &c[i]);
pr[i] = pr[i - 1] + c[i];
prg[i] = prg[i - 1] + g[i];
}
int ans = 0;
for(int i = 1;i <= n; i++){
ans = max(ans, g[i]);
for(int j = i + 1;j <= n; j++){
if(pr[j] - pr[i - 1] >= x[j] - x[i]){
ans = max(ans, prg[j] - prg[i - 1]);
}
}
}
cout << ans;
}
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... |