Submission #541360

#TimeUsernameProblemLanguageResultExecution timeMemory
541360LittleOrangeBulldozer (JOI17_bulldozer)C++17
0 / 100
1 ms324 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...