Submission #1115753

#TimeUsernameProblemLanguageResultExecution timeMemory
1115753staszic_ojuzArt Exhibition (JOI18_art)C++17
0 / 100
1 ms336 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); int n,l,p; cin >> n; vector<pair<int,int>>ciag; vector<int>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); } int wynik=0,wynik2=0; vector<int>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){ 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...