# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139289 | Mahmoud_Adel | Cake 3 (JOI19_cake3) | C++14 | 1406 ms | 143324 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
using namespace std;
typedef long long ll;
const int N = 2e5+5;
ll n, k, cn, ans = -1e18;
ll root[N], lc[N*40], b[N], rc[N*40];
pair<ll, ll> tree[N*40];
vector<pair<ll, ll>> comp;
pair<ll, ll> p[N];
void merge(int node)
{
tree[node].f = tree[lc[node]].f+tree[rc[node]].f;
tree[node].s = tree[lc[node]].s+tree[rc[node]].s;
}
void build(int node = 0, int l=0, int r=n-1)
{
if(l == r)
{
tree[node] = {1, comp[l].f};
//cout << node << " " << tree[node].f << " " << tree[node].s << " | " << l << " " << r << endl;
return ;
}
int mid = (l+r)>>1;
lc[node] = ++cn, rc[node] = ++cn;
build(lc[node], l, mid);
build(rc[node], mid+1, r);
merge(node);
//cout << node << " " << tree[node].f << " " << tree[node].s << " | " << l << " " << r << endl;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |