Submission #159273

#TimeUsernameProblemLanguageResultExecution timeMemory
159273sochoArt Exhibition (JOI18_art)C++14
50 / 100
1076 ms20928 KiB
#include "bits/stdc++.h" using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; vector<pair<long long, long long> > works; for (long long i=0; i<n; i++) { long long siz, val; cin >> siz >> val; works.push_back(make_pair(siz, val)); } sort(works.begin(), works.end()); long long best = LLONG_MIN; for (long long i=0; i<n; i++) { long long mn = works[i].first; long long mx = mn; long long value = 0; for (long long j=i; j<n; j++) { mx = max(mx, works[j].first); value += works[j].second; best = max(best, value - mx + mn); } } cout << best << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...