# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681603 | iskhakkutbilim | Divide and conquer (IZhO14_divide) | C++14 | 1067 ms | 3148 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 int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// ifstream cin("divide.in");
// ofstream cout("divide.out");
int n; cin >> n;
int x[n], g[n], d[n];
for(int i = 0;i < n; i++){
cin >> x[i] >> g[i] >> d[i];
}
int gold[n], energy[n]; gold[0] = g[0], energy[0] = d[0];
for(int i = 1;i < n; i++){
gold[i] = gold[i-1] + g[i];
energy[i] = energy[i-1]+d[i];
}
int answer = 0;
for(int i = 0;i < n; i++){
for(int j = n-1; j >= i; j--){
int s_g = gold[j] - (i > 0 ? gold[i-1] : 0);
int s_e = energy[j] - (i > 0 ? energy[i-1] : 0);
if(s_e >= x[j]-x[i]){
answer = max(answer, s_g);
}
}
}
cout << answer;
return 0;
}
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... |