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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long int
#define endl '\n'
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 100005
#define mod 1000000007
int n;
vector<pii> v;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
v.resize(n);
for (int i = 0; i < n; i++)
cin >> v[i].fir >> v[i].sec.fir >> v[i].sec.sec;
sort(v.begin(), v.end());
int ans = 0;
for (int l = 0; l < n; l++)
{
int g = 0, e = 0;
for (int r = l; r < n; r++)
{
g += v[r].sec.fir;
e += v[r].sec.sec;
if (e >= (v[r].fir - v[l].fir))
ans = max(ans, g);
}
}
cout << ans << endl;
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... |