# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
926183 | 2024-02-12T16:55:49 Z | Art_ogo | Art Exhibition (JOI18_art) | C++17 | 0 ms | 0 KB |
#include <iostream> #include <vector> #include <set> #include <map> #include <algorithm> //#define int long long */ #define ll long long #define fi first #define se second #define ve vector using namespace std; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define all(x) x.begin(), x.end() const int MAXN = 3e5+10; signed main(){ int n; cin >> n; ve<pll> v(n); for(auto& i : v) cin >> i.fi >> i.se; sort(all(v)); ll res = LLONG_MIN; ll sum = 0; ll mx = 0; for(int i = 0; i < n; i++){ mx = max(mx, v[i].fi - sum); sum += v[i].se; res = max(res, mx + sum - v[i].fi); } cout << res << "\n"; }