# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
248885 | rocks03 | Art Exhibition (JOI18_art) | C++14 | 0 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<pii> v(N);
for(int i = 0; i < N; i++) cin >> v[i].ff >> v[i].ss;
sort(v.begin(), v.end());
ll ans = v[0].ss;
set<pii> s; s.insert({v[0].ss+v[0].ff, 0});
ll sum = v[0].ss;
for(int i = 1; i < N; i++){
pii best = *s.rbegin();
ans = max(ans, best.ff - v[i].ff + v[i].ss);
sum += v[i].ss;
s.insert({sum+v[0].ff, 0});
s.insert({best.ff - v[i].ff + v[i].ss, best.ss});
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |