Submission #543003

#TimeUsernameProblemLanguageResultExecution timeMemory
543003fuad27Art Exhibition (JOI18_art)C++17
100 / 100
562 ms20756 KiB
#include<bits/stdc++.h> using namespace std; int main () { int n; cin >> n; pair<long long, long long> arr[n]; for(int i = 0;i<n;i++) { cin >> arr[i].first >> arr[i].second; } sort(arr, arr+n); long long sum = arr[0].second; long long ans = sum; for(int i = 1;i<n;i++) { sum = max(sum+arr[i].second - (arr[i].first - arr[i-1].first), arr[i].second); ans = max(ans, sum); } cout << ans << "\n"; 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...