#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(0);cin.tie();
int n;
cin >> n;
vector<pair<ll,ll>> a(n);
vector<pair<ll,ll>> b(n);
for (int i = 0;i<n;i++){
ll x,y,w;
cin >> x >> y >> w;
a[i] = {x,w};
b[i] = {y,w};
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector<ll> sum(n+1);
sum[0] = 0;
for (int i = 0;i<n;i++){
sum[i+1] = sum[i]+a[i].second;
}
ll m = 0;
ll ans = 0;
for (int i = 1;i<=n;i++){
ans = max(ans,sum[i]-m);
m = min(m,sum[i]);
}
sum[0] = 0;
for (int i = 0;i<n;i++){
sum[i+1] = sum[i]+b[i].second;
}
m = 0;
for (int i = 1;i<=n;i++){
ans = max(ans,sum[i]-m);
m = min(m,sum[i]);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |