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
int32_t main(void) {
int n;
cin >> n;
vector <pair <int,pair <int,int>>> a;
for(int i = 0; i < n; i ++) {
int d, x, y;
cin >> d >> x >> y;
a.push_back({d, {y, x}});
}
vector <int> gold(n), energy(n);
gold[0] = a[0].second.second;
energy[0] = a[0].second.first;
for(int i = 1; i < n; i ++) {
gold[i] = gold[i - 1] + a[i].second.second;
energy[i] = energy[i - 1] + a[i].second.first;
}
int mx = 0;
for(int i = 0; i < n; i ++) {
mx = max(mx, a[i].second.second);
for(int j = i + 1; j < n; j ++) {
if(a[i].first + energy[j] >= a[j].first + (i-1<0?0:energy[i-1])) {
mx = max(mx, gold[j] - (i-1 < 0 ? 0 : gold[i - 1]));
}
// cout << cursum << " " << curgold << "\n";
}
}
cout << mx;
return false;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |