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;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
#define FOR(i, a) for (int i=0; i<(a); i++)
#define all(x) x.begin(), x.end()
#define gcd __gcd
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
//const int dr[4] = {-1, 0, 1, 0}, dc[4] = {0, 1, 0, -1};
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 5;
struct pt{
int x, y, w;
} a[N];
int n;
void sub1(){
sort(a + 1, a + n + 1, [&](pt a, pt b){
return a.x < b.x;
});
vll s(n + 1);
for(int i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i].w;
ll ans = 0;
for(int i = 1; i <= n; ++i)
for(int j = i; j <= n; ++j)
ans = max(ans, s[j] - s[i - 1]);
cout << ans;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
bool check1 = 1;
for(int i = 1; i <= n; ++i){
cin >> a[i].x >> a[i].y >> a[i].w;
check1 &= (a[i].y == 0);
}
if(check1){
sub1();
exit(0);
}
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... |