# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
719435 | rainboy | Happiness (Balkan15_HAPPINESS) | C++17 | 1130 ms | 22960 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 "happiness.h"
const int N = 200000, Q = 100000, K = 5, N_ = N + Q * K + 1;
const long long A = 1000000000001;
long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int zz[N_], ll[N_], rr[N_], cc[N_], u_, l_, r_; long long xx[N_], ss[N_], dd[N_];
int node(long long x, int c) {
static int _ = 1;
zz[_] = rand_();
xx[_] = x, cc[_] = c;
ss[_] = x <= A / c ? x * c : A;
dd[_] = x;
return _++;
}
void pul(int u) {
int l = ll[u], r = rr[u], c = cc[u];
long long x = xx[u], y = x <= A / c ? x * c : A;
ss[u] = min(min(ss[l] + y, A) + ss[r], A);
dd[u] = max(max(dd[l], x - ss[l]), dd[r] - min(ss[l] + y, A));
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... |