이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define foreach(it, S) for (__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define all(x) x.begin(), x.end()
#define endl '\n'
#define _ ios_base :: sync_with_stdio(false); cin.tie(NULL);
#ifdef inputf
#define fname ""
#else
#define fname "" // <- Here
#endif
const double eps = 1e-9;
const int MaxN = int(2e5) + 256;
const int MOD = int(1e9) + 7;
template <typename T> inline T gcd(T a, T b) {
return b ? gcd (b, a % b) : a;
}
inline bool Palindrome(const string& s) {
return equal(s.begin(), s.end(), s.rbegin());
}
ll x[MaxN], g[MaxN], e[MaxN];
int main() { // _
#ifdef lcl
freopen(fname".in", "r", stdin);
freopen(fname".out", "w", stdout);
#endif
int n; scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%lld%lld%lld", x + i, g + i, e + i);
e[i] += e[i - 1];
g[i] += g[i - 1];
}
ll res = 0;
int l = 1, r = 1;
while (l <= r) {
if (r == n) {
while (l <= r) {
if (x[r] - x[l] <= e[r] - e[l - 1])
res = max(res, g[r] - g[l - 1]);
++l;
}
break;
}
while (r < n && x[r] - x[l] <= e[r] - e[l - 1]) {
res = max(res, g[r] - g[l - 1]);
++r;
}
++l;
}
printf("%lld", res);
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... |