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 num long long
#define di pair<num, num>
#define cm pair<int, di>
#define vc vector<cm>
#define pos first
#define gold second.first
#define energy second.second
cm read () {
int x, g, e;
cin >> x >> g >> e;
return { x, { g, e } };
}
vc camps;
int c_size (int left, int right) {
return camps[right].pos - camps[left].pos;
}
int main () {
int N;
cin >> N;
for (int i = 0; i < N; i ++)
camps.push_back(read());
num energyCount = 0;
num goldCount = 0;
num maxGoldCount = 0;
int left = 0;
for (int right = 0; right < N; right ++) {
energyCount += camps[right].energy;
goldCount += camps[right].gold;
while (energyCount < c_size(left, right)) {
energyCount -= camps[left].energy;
goldCount -= camps[left].gold;
left ++;
}
maxGoldCount = max(goldCount, maxGoldCount);
}
cout << maxGoldCount << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |