Submission #503557

#TimeUsernameProblemLanguageResultExecution timeMemory
503557BY_KUTBILIMArt Exhibition (JOI18_art)C++17
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 5e5+5; ll n, sum, ans = -1e18, mx; pair<int,int> 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...