제출 #833867

#제출 시각아이디문제언어결과실행 시간메모리
833867baqqon_금 캐기 (IZhO14_divide)C++17
0 / 100
0 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...