이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |