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;
#define endl '\n'
#define inf32 ((int)1e9 + 7)
#define inf64 ((long long)1e18 + 7)
#define MASK32(x) (1 << (x))
#define MASK64(x) (1ll << (x))
#define BIT(mask, i) (((mask) >> (i)) & 1)
#define all(a) begin(a), end(a)
#define isz(a) ((int)a.size())
const int N = 2e3 + 1;
int n;
struct Nigga {
int x, y;
long long v;
} a[N];
void sub1() {
sort(a + 1, a + n + 1, [](const Nigga& lhs, const Nigga& rhs) {
return lhs.x < rhs.x;
});
long long res = 0, pref = 0, mn = 0;
for(int i = 1; i <= n; ++i) {
pref += a[i].v;
mn = min(mn, pref);
res = max(res, pref - mn);
}
cout << res;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
bool f = 1;
for(int i = 1; i <= n; ++i) {
cin >> a[i].x >> a[i].y >> a[i].v;
f &= (a[i].y == 0);
}
if(f) sub1();
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |