제출 #1120999

#제출 시각아이디문제언어결과실행 시간메모리
1120999Tsagana금 캐기 (IZhO14_divide)C++14
0 / 100
1 ms336 KiB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second

using namespace std;

int g[100001];
int e[100001];
vector<int> v;

void solve () {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x >> g[i] >> e[i]; v.pb(x);
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int c = e[i]-1;
		int val = g[i];
		int l = i, r = i+1;

		while (r < n) {
			if (v[r] - v[l] > c + e[r]) break ;
			c += e[r] - (v[r] - v[l]);
			val += g[r];
			l = r; r = l + 1;
		}
		ans = max(ans, val);
	}
	for (int i = n-1; i >= 0; i--) {
		int c = e[i]-1;
		int val = g[i];
		int l = i-1, r = i;

		while (l >= 0) {
			if (v[r] - v[l] > c + e[l]) break ;
			c += e[l] - (v[r] - v[l]);
			val += g[r];
			r = l; l = r - 1;
		}
		ans = max(ans, val);
	}
	cout << ans;
}
signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...