Submission #48954

#TimeUsernameProblemLanguageResultExecution timeMemory
48954faishol27Art Exhibition (JOI18_art)C++14
100 / 100
399 ms9120 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; } ll optimized(){ cnt += data[1].val; ans = max(cnt, ans); 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){ cnt = data[i].val; } ans = max(ans, cnt); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 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); optimized(); cout << ans << endl; }

Compilation message (stderr)

art.cpp: In function 'll optimized()':
art.cpp:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
 } 
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...