# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1129473 | notkai | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 3101 ms | 246544 KiB |
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000000
typedef int i1;
i1 n;
vector<i1> arr(MAXN);
vector<vector<i1>> sortedsegment(4*MAXN,vector<i1>(0));
vector<i1> segment(4*MAXN,0);
void calcsorted(i1 treeindex, i1 onleft=0, i1 onright=n-1){
for (i1 i = onleft; i <= onright; i++){
sortedsegment[treeindex].push_back(arr[i]);
}
sort(sortedsegment[treeindex].begin(), sortedsegment[treeindex].end());
if (onleft != onright){
calcsorted(treeindex*2+1, onleft, (onleft+onright)/2);
calcsorted(treeindex*2+2, (onleft+onright+2)/2, onright);
}
}
void calcsegtree(i1 treeindex, i1 onleft = 0, i1 onright = n-1){
if (onleft == onright){
segment[treeindex] = 0;
return;
}
calcsegtree(treeindex*2+1, onleft, (onleft+onright)/2);
calcsegtree(treeindex*2+2, (onleft+onright+2)/2, onright);
segment[treeindex] = max(segment[treeindex*2+1], segment[treeindex*2+2]);
i1 maxvalue = sortedsegment[treeindex*2+1][sortedsegment[treeindex*2+1].size()-1];
auto it = lower_bound(sortedsegment[treeindex*2+2].begin(), sortedsegment[treeindex*2+2].end(), maxvalue);
if (it != sortedsegment[treeindex*2+2].begin()){
it--;
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |