Submission #48951

#TimeUsernameProblemLanguageResultExecution timeMemory
48951faishol27Art Exhibition (JOI18_art)C++14
0 / 100
2 ms248 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define PUB push_back struct art{ ll sz, val; }; int N; ll ans = 0, cnt = 0; vector<art> data; bool comp(art a, art b){ if(a.sz == b.sz) return a.val < b.val; return a.sz < b.sz; } int main(){ cin >> N; data.PUB({0,0}); for(int i=1;i<=N;i++){ ll a, b; cin >> a >> b; data.PUB({a, b}); } sort(data.begin(), data.end(), comp); cnt += data[1].val; ans = cnt; for(int i=2;i<=N;i++){ cnt += data[i].val-(data[i].sz-data[i-1].sz); if(cnt <= 0){ cnt = data[i].val; } ans = max(ans, cnt); } cout << ans << 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...