# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
162590 | fenech20 | Art Exhibition (JOI18_art) | C++14 | 267 ms | 8568 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.
/**
* Martin Leshko (leshko.martin@gmail.com)
*/
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define sz(a) (int)a.size()
const int N = 300001;
int main() {
int n;
scanf("%d", &n);
vector< pair<long long, long long> > a(n);
for (int i = 0; i < n; i++) {
long long x, y;
scanf("%lld%lld", &x, &y);
a[i] = {x, y};
}
sort(a.begin(), a.end());
long long prefix = 0, mn = 0x3f3f3f3f3f3f3f3f, ans = -0x3f3f3f3f3f3f3f3f;
for (int i = 0; i < n; i++) {
prefix += a[i].second;
mn = min(mn, prefix - a[i].second - a[i].first);
ans = max(ans, prefix - a[i].first - mn);
}
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... |