이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct camp{
long long x, g, e;
};
signed main() {
long long n, maxx = 0, sumx = 0, sumg= 0, sume = 0, left = 0, right = 0;
cin >> n;
vector<camp> vec(n);
for (int i = 0; i< n; i++) {
cin >> vec[i].x >> vec[i].g >> vec[i].e;
}
while (left <=n-1){
sumx = vec[right].x-vec[left].x;
sume +=vec[right].e;
if(sume>=sumx && right<n-1){
sumg += vec[right].g;
maxx = max(sumg,maxx);
right++;
}else{
sumg-=vec[left].g;
maxx = max(sumg,maxx);
sume-=vec[left].e;
sume-=vec[right].e;
left++;
if (left>right){
sume+=vec[right].e;
right = left;
}
}
sume = abs(sume);
sumg = abs(sumg);
sumx = abs(sumx);
}
maxx = max(sumg,maxx);
cout << maxx;
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... |