# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71443 | win11905 | Art Exhibition (JOI18_art) | C++11 | 365 ms | 10616 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 long long long
#define pll pair<long, long>
#define x first
#define y second
int n;
long pref, ans, lhs = -1e18;
int main() {
scanf("%d", &n);
vector<pll> V; V.reserve(n+1);
for(int i = 0; i < n; ++i) {
long a, b; scanf("%lld %lld", &a, &b);
V.emplace_back(a, b);
}
sort(V.begin(), V.end());
for(int i = 0; i < n; ++i) {
long a, b; tie(a, b) = V[i];
lhs = max(lhs, a - pref);
pref += b;
ans = max(ans, pref - a + lhs);
}
printf("%lld\n", 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... |