Submission #1115649

#TimeUsernameProblemLanguageResultExecution timeMemory
1115649staszic_ojuzArt Exhibition (JOI18_art)C++17
100 / 100
377 ms22088 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main(){ int n; cin >> n; pair<ll, ll> obr[n]; for(int i = 0; i < n; i++){ cin >> obr[i].first; cin >> obr[i].second; } ll pre[n]; sort(obr, obr + n); pre[n-1] = obr[n-1].second; for(int i = n-2; i >= 0; i--){ pre[i] = obr[i].second + obr[i].first - obr[i+1].first; } ll suma = 0; ll wynik = 0; for(int i = n-1; i >= 0; i--){ suma += pre[i]; suma = max(suma, obr[i].second); wynik = max(wynik, suma); } cout << wynik << "\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...