| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 967979 | vjudge1 | Art Exhibition (JOI18_art) | C++17 | 153 ms | 22628 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 <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
#define fr first
#define se second
const int N = 5e5+2;
pii a[N];
ll qs[N], curr = 0ll, ans = 0ll, currmn = 1e15, currmx = -1e15, mn, mx;
int main()
{
int n; scanf("%d", &n);
for (int i = 1;i <= n;i++) scanf("%lld %lld", &a[i].fr, &a[i].se);
sort(a+1, a+n+1);
for (int i = 1; i <= n; ++i){
mn = min(currmn, a[i].fr);
mx = max(currmx, a[i].fr);
if (curr + a[i].se - (mx - mn) < a[i].se){
curr = a[i].se;
currmn = a[i].fr;
currmx = a[i].fr;
}
else{
currmn = mn;
currmx = mx;
curr += a[i].se;
}
ans = max(ans, curr - (currmx - currmn));
}
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... | ||||
