# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144236 | osaaateiasavtnl | Cake 3 (JOI19_cake3) | C++14 | 1460 ms | 206304 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;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
const int N = 2e5 + 7, INF = 1e18 + 7;
int n, m;
struct El { int v, c; } a[N];
struct Node { int cnt, sum; Node *l, *r; Node () { cnt = sum = 0; l = r = NULL; } };
vector <int> c;
Node *build(int tl, int tr) {
Node *ans = new Node();
if (tl == tr) return ans;
int tm = (tl + tr) >> 1;
ans->l = build(tl, tm); ans->r = build(tm + 1, tr);
return ans;
}
void relax(Node *t) { t->cnt = t->l->cnt + t->r->cnt; t->sum = t->l->sum + t->r->sum; }
Node *add(Node *t, int tl, int tr, int p) {
Node *ans = new Node();
if (tl == tr) { ans->cnt = t->cnt + 1; ans->sum = t->sum + c[p]; return ans; }
int tm = (tl + tr) >> 1;
if (p <= tm) { ans->l = add(t->l, tl, tm, p); ans->r = t->r; }
else { ans->l = t->l; ans->r = add(t->r, tm + 1, tr, p); }
relax(ans); return ans;
}
int get(Node *l, Node *r, int tl, int tr, int k) {
if (tl == tr) return c[tl] * k;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |