# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
620195 | veehz | Cake 3 (JOI19_cake3) | C++17 | 4067 ms | 4420 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;
typedef long long ll;
const int MAXN = 200005;
int n, m;
ll ans[MAXN];
vector<array<ll, 2>> c; // c, v
ll solve2(int r, int optl, int optr) {
// l in [optl, optr]
priority_queue<ll, vector<ll>, greater<ll>> q; // v
ll sum = 0;
for (int i = r; i > r-m; i--) {
q.push(c[i][1]);
sum += c[i][1];
}
ll ans = sum - 2 * (c[r][0] - c[r - m + 1][0]);
for (int i = r-m; i >= optl; i--) {
q.push(c[i][1]);
sum += c[i][1];
sum -= q.top();
q.pop();
ans = max(ans, sum - 2*(c[r][0] - c[i][0]));
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |