Submission #913854

#TimeUsernameProblemLanguageResultExecution timeMemory
913854lukameladzeArt Exhibition (JOI18_art)C++17
10 / 100
1 ms444 KiB
#include<bits/stdc++.h> using namespace std; int s[500001]; #define int long long int32_t main(){ int n, ans = 0,maxx = 0; cin >> n; pair<int, int> p[n+1]; s[0] = 0; for(int i = 1; i <= n; i++){ cin >> p[i].first >> p[i].second; s[i] = 0; } sort(p+1, p+n+1); for (int i = 1; i <= n; i++) s[i] = s[i - 1] + p[i].second; for(int i = 1; i <= n; i++){ maxx = max(maxx, p[i].first - s[i - 1]); ans = max(ans, s[i] + maxx - p[i].first); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...