Submission #1129473

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11294732024-12-25 03:35:25notkaiHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
64 / 100
3101 ms246544 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--;
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...