Submission #315806

#TimeUsernameProblemLanguageResultExecution timeMemory
315806nandonathanielArt Exhibition (JOI18_art)C++14
100 / 100
203 ms20728 KiB
#include<bits/stdc++.h> using namespace std; pair<long long,long long> arr[500005]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin >> n; for(int i=1;i<=n;i++){ cin >> arr[i].first >> arr[i].second; } sort(arr+1,arr+n+1); long long ans=arr[1].second,ret=arr[1].second; for(int i=2;i<=n;i++){ ret+=(arr[i].second-arr[i].first+arr[i-1].first); ret=max(ret,arr[i].second); ans=max(ans,ret); } 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...