Submission #700114

#TimeUsernameProblemLanguageResultExecution timeMemory
700114dsyzArt Exhibition (JOI18_art)C++17
100 / 100
198 ms24616 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define MAXN (1000005) int main() { ios_base::sync_with_stdio(false);cin.tie(0); ll N; cin>>N; pair<ll,ll> arr[N]; ll maximum = 0; for(ll i = 0;i < N;i++){ cin>>arr[i].first>>arr[i].second; } sort(arr,arr + N); ll psumB[N + 1]; //1-indexed psumB[0] = 0; for(ll i = 1;i <= N;i++){ psumB[i] = psumB[i - 1] + arr[i - 1].second; } ll maxL = -1e18; for(ll i = 0;i < N;i++){ maxL = max(maxL,arr[i].first - psumB[i]); maximum = max(maximum,maxL + psumB[i + 1] - arr[i].first); } cout<<maximum<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...