제출 #1235957

#제출 시각아이디문제언어결과실행 시간메모리
1235957lanaskarica금 캐기 (IZhO14_divide)C++20
48 / 100
13 ms580 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define pii pair <int, int>
#define pll pair <ll, ll>
#define fi first
#define se second

const int MAXN = 5010;

pair <ll, pll> arr[MAXN];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++) cin >> arr[i].fi >> arr[i].se.fi >> arr[i].se.se;
	
	ll rj = 0;
	for (int i = 0; i < n; i++) {
		ll zb = 0, gold = 0;
		for (int j = i; j < n; j++) {
			zb += arr[j].se.se;
			gold += arr[j].se.fi;
			if (zb >= arr[j].fi - arr[i].fi) rj = max(rj, gold);
		}
	}
	cout << rj << "\n";
	
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...