Submission #1115755

#TimeUsernameProblemLanguageResultExecution timeMemory
1115755staszic_ojuzArt Exhibition (JOI18_art)C++17
100 / 100
146 ms30644 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,l,p; cin >> n; vector<pair<ll,ll>>ciag; vector<ll>ciag2(1); for(int i=0;i<n;++i){ cin >> l >> p; ciag.push_back({l,p}); } sort(ciag.begin(),ciag.end()); for(int i=0;i<n;++i){ ciag2.push_back(ciag2[i]+ciag[i].second); } /*for(int i=0;i<ciag2.size();++i){ cout << ciag2[i] << ' '; } cout << endl; */ ll wynik=0,wynik2=0; vector<ll>maksy; for(int i=0;i<n;++i){ wynik=max(ciag2[i]*-1+ciag[i].first,wynik); maksy.push_back(wynik); } /*for(int i=0;i<n;++i){ cout << maksy[i] << ' '; } cout << endl; */ for(int i=0;i<n;++i){ wynik2=max(ciag2[i+1]-ciag[i].first+maksy[i],wynik2); } cout << wynik2; 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...