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 "wall.h"
#include <bits/stdc++.h>
using namespace std;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
map<int,vector<int>> beg,end;
set<int> low,high;
for(int i=0; i<k; i++){
beg[left[i]].push_back(i);
end[right[i]+1].push_back(i);
}
for(int i=0; i<n; i++){
for(auto j:beg[i]){
if(op[j]==1) low.insert(height[j]);
else high.insert(height[j]);
}
for(auto j:end[i]){
if(op[j]==1) low.erase(low.find(height[j]));
else high.erase(high.find(height[j]));
}
finalHeight[i]=min(low.empty()?0:*next(low.end(),-1), high.empty()?1000000:*(high.begin()));
}
}
# | 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... |