Submission #315801

#TimeUsernameProblemLanguageResultExecution timeMemory
315801nandonathanielArt Exhibition (JOI18_art)C++14
0 / 100
1 ms384 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); ans=max(ans,ret); if(ret<0){ ret=arr[i].second; } } 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...