# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103989 | igba | Fortune Telling 2 (JOI14_fortune_telling2) | C++17 | 3103 ms | 198092 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 int MAXN = 2 * 100100, MAXK = 2 * 100100, MAXA = 1e9 + 1e4;
int n, k, a[MAXN], b[MAXN], t[MAXK];
long long ans = 0;
struct no
{
int cnt;
no *l, *r;
no(int cnt = 0) : cnt(cnt), l(nullptr), r(nullptr)
{}
};
inline int getcnt(no *n) { return (n ? n->cnt : 0); }
no* upd(no* n, int pos, int val = 1, int beg = 1, int end = MAXA)
{
if(beg == end)
return new no(getcnt(n) + val);
no* ans = (n ? new no(*n) : new no());
int mid = (beg + end) >> 1;
if(pos <= mid)
ans->l = upd(ans->l, pos, val, beg, mid);
else
ans->r = upd(ans->r, pos, val, mid + 1, end);
ans->cnt = getcnt(ans->l) + getcnt(ans->r);
return ans;
}
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... |