This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
cout << ans;
}
signed main() {IOS solve(); 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... |