Submission #853335

#TimeUsernameProblemLanguageResultExecution timeMemory
853335willychanArt Exhibition (JOI18_art)C++14
0 / 100
1 ms344 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; //#include<bits/extc++.h> //__gnu_pbds int n; vector<pair<ll,ll> > arr; int main(){ ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>n; arr.resize(n); for(int i=0;i<n;i++){ cin>>arr[i].first>>arr[i].second; } sort(arr.begin(),arr.end()); ll maxn[n] = {0}; maxn[0] = arr[0].first+arr[0].second; ll ans = 0; for(int i=1;i<n;i++){ ans = max(ans,maxn[i-1]+arr[i].second-arr[i].first) ; maxn[i] = max(maxn[i-1]+arr[i].second,arr[i].second+arr[i].first); } 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...