이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
long long x[100005], g[100005], d[100005], p[100005];
int main(){
scanf("%d",&n);
for (int i=1; i<=n; i++) {
scanf("%lld %lld %lld",&x[i],&g[i],&d[i]);
d[i] += d[i-1];
g[i] += g[i-1];
p[i] = d[i] - x[i];
}
for (int i=n-1; i; i--) {
p[i] = max(p[i],p[i+1]);
}
long long r = 0;
for (int i=1; i<=n; i++) {
int s = i, e = n;
while (s != e) {
int m = (s+e+1)/2;
if(d[i-1] - x[i] <= p[m]) s = m;
else e = m-1;
}
if(d[i-1] - x[i] <= p[s]){
r = max(r,g[s] - g[i-1]);
}
}
printf("%lld",r);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |