# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
542054 | lunchbox | Art Exhibition (JOI18_art) | C++17 | 1 ms | 212 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;
int main() {
long long ans, mx;
int n;
scanf("%d", &n);
vector<pair<long long, long long>> a(n);
for (auto &[x, y] : a)
scanf("%lld%lld", &x, &y);
sort(a.begin(), a.end());
for (int i = 0; i + 1 < n; i++)
a[i + 1].second += a[i].second;
ans = mx = 0;
for (int i = 0; i < n; i++) {
ans = max(ans, a[i].second - a[i].first + mx);
mx = max(mx, a[i].first - (i == 0 ? 0 : a[i - 1].second));
}
printf("%lld\n", ans);
return 0;
}
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... |