Submission #503563

#TimeUsernameProblemLanguageResultExecution timeMemory
503563BY_KUTBILIMArt Exhibition (JOI18_art)C++17
100 / 100
192 ms18952 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 5e5+5; ll n, sum, ans = -1e18, mx; pair<ll,ll> a[N]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i].first >> a[i].second; } sort(a + 1, a + n + 1); mx = -a[1].first; for(int i = 1; i <= n; i++){ sum += a[i].second; ans = max(ans, (sum - a[i].first) - mx); mx = min(mx, sum - a[i+1].first); } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...