# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
163182 | fenech20 | Art Exhibition (JOI18_art) | C++14 | 391 ms | 20984 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()
typedef long long ll;
int main() {
ll n;
scanf("%lld", &n);
vector<pair<ll, ll> > a(n);
for (int i = 0; i < n; i++) {
scanf("%lld%lld", &a[i].first, &a[i].second);
}
sort(a.begin(), a.end());
ll prefix = 0, ans = -0x3f33f3f3f3f3f, mn = 0x3f3f3f3f3f3f;
for (int i = 0; i < n; i++) {
mn = min(mn, prefix - a[i].first);
prefix += a[i].second;
ans = max(ans, prefix - mn - a[i].first);
// fprintf(stderr, "mn = %d, prefix = %d, ans = %d\n", mn, prefix, ans);
}
printf("%lld", 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... |