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>
using namespace std;
const int MaxN = 1e5 + 17;
int n, ind = 1, Sum, Max, Sz;
pair < int, pair < int, int > > p[MaxN];
int main ()
{
#ifdef Elibay
freopen (".in", "r", stdin);
#endif
scanf ("%d", &n);
for (int i = 1; i <= n; ++ i)
scanf ("%d%d%d", &p[i].first, &p[i].second.second, &p[i].second.first);
sort (p + 1, p + n + 1);
for (int i = 1; i <= n; ++ i)
{
Sz += p[i].second.first;
int r = p[i].first;
while (p[ind].first < r - Sz)
Sum -= p[ind].second.second, ind ++, Sz -= p[ind].second.first;
Sum += p[i].second.second;
Max = max (Max, Sum);
}
cout << Max;
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... |