# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
220111 | rama_pang | Cake 3 (JOI19_cake3) | C++14 | 1761 ms | 17004 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;
const long long INF = 1e18;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
class SegmentTree {
private:
int sz;
vector<int> A;
vector<pair<long long, int>> tree;
void Update(int n, int tl, int tr, int pos, int activate) {
if (tl == tr) return void(tree[n] = {activate ? A[pos] : 0, activate});
int mid = (tl + tr) / 2;
int lc = n + 1;
int rc = n + 2 * (mid - tl + 1);
if (pos <= mid) {
Update(lc, tl, mid, pos, activate);
} else {
Update(rc, mid + 1, tr, pos, activate);
}
tree[n] = {tree[lc].first + tree[rc].first, tree[lc].second + tree[rc].second};
}
long long Query(int n, int tl, int tr, int key) { // sum of key minimum elements
if (key <= 0) return 0;
if (tree[n].second <= key) return tree[n].first;
int mid = (tl + tr) / 2;
int lc = n + 1;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |