Submission #744346

#TimeUsernameProblemLanguageResultExecution timeMemory
744346MONArt Exhibition (JOI18_art)C++14
0 / 100
0 ms212 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll = long long; struct art { ll sz,v; art(ll &a,ll &b) : sz(a),v(b) {}; bool operator <(const art &other) const { return sz < other.sz; } }; int main() { vector<art> arta; int n; ll a,b; cin >> n; for(int i = 1; i <= n ; i++) { cin >> a >> b; arta.push_back(art(a,b)); } sort(arta.begin(),arta.end()); ll suma = arta[0].v; ll minim = -arta[0].sz,ans = 0,last = suma; for(int i = 1; i < n ; i++) { suma += arta[i].v; ans = max(ans,suma - arta[i].sz - minim); minim = min(minim,last - arta[i].sz); last = suma; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...