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 <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9;
struct point{
ll x, y, w;
};
void sub1(int n, vector<point> a){
sort(a.begin(), a.end(), [&](point a, point b){return a.x < b.x;});
vector<ll> f(n+1, 0);
ll ans = 0;
for(int i = 1; i <= n; i++){
f[i] = max(f[i-1]+a[i].w, a[i].w);
ans = max(ans, f[i]);
}
cout << ans;
}
void solve(){
int n;
cin >> n;
vector<point> a(n+1);
bool issub1 = true;
for(int i = 1; i <= n; i++){
cin >> a[i].x >> a[i].y >> a[i].w;
if(a[i].y != 0) issub1 = false;
}
if(issub1){
sub1(n, a);
return;
}
sub1(n, a);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("TRUFFLE.inp", "r", stdin);
//freopen("TRUFFLE.out", "w", stdout);
solve();
}
# | 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... |