Submission #648995

#TimeUsernameProblemLanguageResultExecution timeMemory
648995tigarArt Exhibition (JOI18_art)C++14
100 / 100
262 ms32560 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; pair<ll, ll>dela[500050]; ll prefiksne[500050], manje[500050], vece[500050]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i=0; i<n; i++)cin>>dela[i].first>>dela[i].second; sort(dela, dela+n); prefiksne[0]=dela[0].second; for(int i=1; i<n; i++)prefiksne[i]=dela[i].second+prefiksne[i-1]; manje[0]=dela[0].first; vece[0]=LONG_MIN; for(int i=1; i<n; i++) { vece[i]=prefiksne[i]-dela[i].first; manje[i]=dela[i].first-prefiksne[i-1]; } ll mn=LONG_MIN, rez=LONG_MIN; //for(int i=0; i<n; i++)cout<<manje[i]<<" "<<vece[i]<<"/n"; for(int i=0; i<n; i++) { mn=max(mn, manje[i]); rez=max(rez, mn+vece[i]); } cout<<rez; 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...