# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1141153 | anmattroi | Cake 3 (JOI19_cake3) | C++17 | 1 ms | 328 KiB |
/*******************************************
Task: JOI19_Cake3
Link: https://oj.uz/problem/view/JOI19_cake3
*******************************************/
#include <bits/stdc++.h>
#define maxn 200005
#define fi first
#define se second
using namespace std;
using ii = pair<int, int>;
using li = pair<int64_t, int>;
int n, k;
ii a[maxn];
li f[maxn];
li solve_lambda(int64_t lambda) {
li mx = {LLONG_MIN/100, 0};
for (int i = 1; i <= n; i++) {
f[i] = {a[i].fi + 2LL * a[i].se - lambda, 1};
f[i] = max(f[i], li{mx.fi+a[i].fi - lambda, mx.se+1});
mx = max(mx, f[i]);
}
mx = {LLONG_MIN, 0};
for (int i = 1; i <= n; i++) mx = max(mx, li{f[i].fi - 2LL * a[i].se, f[i].se});
return mx;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |