# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126359 | EntityIT | Art Exhibition (JOI18_art) | C++14 | 272 ms | 12604 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 fi first
#define se second
const int N = (int)5e5 + 5;
const long long infll = (long long)1e18 + 123;
int n;
long long ans = -infll, prv = -infll;
pair<long long, long long> a[N];
int main () {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%lld %lld", &a[i].fi, &a[i].se);
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i) a[i].se += a[i - 1].se;
for (int i = 1; i <= n; ++i) {
prv = max(prv, a[i].fi - a[i - 1].se);
ans = max(ans, a[i].se - a[i].fi + prv);
}
printf("%lld", 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... |