이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("divide.in", "r", stdin);
//freopen("divide.out", "w", stdout);
int n;
cin >> n;
int x[n] , g[n] , e[n] ;
for(int i=1; i<=n; i++){
cin >> x[i] >> g[i] >> e[i];
}
int rud = g[1];
int gold = g[1], energy = e[1];
for(int i=2; i<=n; i++){
int len = x[i] - x[i-1];
if(len <= energy + e[i]){
gold += g[i];
energy += e[i] - len;
}
else{
gold = g[i];
energy = e[i];
}
rud = max(rud, gold);
}
cout << gold;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |