이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n, x, g, d;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
ll prefd[n], prefg[n], xx[n];
ll mx = 0;
for (int i = 0; i < n; i++) {
cin >> x >> g >> d;
xx[i] = x;
if (i == 0) {
prefg[i] = g;
prefd[i] = d;
}
else {
prefd[i] = prefd[i - 1] + d;
prefg[i] = prefg[i - 1] + g;
}
for (int j = 0; j <= i; j++) {
if (j == 0){
if (xx[i] - xx[j] <= prefd[i]) {
mx = max(mx, prefg[i]);
}
}
else if (xx[i] - xx[j] <= prefd[i] - prefd[j - 1]) {
mx = max(mx, prefg[i] - prefg[j - 1]);
}
}
}
cout << mx;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |