# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
459653 | Hamed5001 | Art Exhibition (JOI18_art) | C++14 | 0 ms | 204 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;
typedef long long ll;
void solve() {
int N;
cin >> N;
vector<pair<ll, ll>> AB(N);
for (auto& [a, b] : AB)
cin >> a >> b;
sort(AB.begin(), AB.end());
for (int i = 1; i < N; i++)
AB[i].second += AB[i-1].second;
ll ans = AB[0].second;
for (int l = 0, r = 1; r < N; ++r) {
ll tmp1 = AB[r].second - (l ? AB[l-1].second : 0) - AB[r].first + AB[l].first;
ll tmp2 = AB[r].second - AB[r-1].second - AB[r].first*2;
if (tmp2 >= tmp1) l = r;
ans = max({ans, tmp1, tmp2});
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
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... |