# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
697600 | keta_tsimakuridze | Candies (JOI18_candies) | C++14 | 495 ms | 69612 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>
#define f first
#define s second
#define int long long
#define pii pair<int,int>
#define Pii pair<int,pii>
using namespace std;
const int N = 2e5 + 5, inf = 1e14; // !
int ans[N], a[N], p[N];
set<pii> S;
set<Pii> s;
struct node {
pair<int, pii> best[2];
pii R[2], L[2];
} t[4 * N], Z;
node merge(node a, node b) {
node c;
for(int t = 0; t < 2; t++) c.R[t] = max(a.R[t], b.R[t]), c.L[t] = min(a.L[t], b.L[t]);
for(int t = 0; t < 2; t++)
c.best[t] = max(a.best[t], b.best[t]),
c.best[t] = max(c.best[t], {{b.R[t].f - a.L[t^1].f}, {a.L[t^1].s + 1, b.R[t].s}});
return c;
}
void build(int u, int l, int r) {
if(l == r) {
t[u].best[0].f = t[u].best[1].f = -inf;
t[u].R[l % 2] = {(l % 2 ? p[l] : -p[l]), l}; t[u].R[1 - l % 2].f = -inf;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |