#include "wall.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
using namespace std;
const int maxK=5e5;
const int maxN=2e6;
struct point{
int x, y, z;
};
vector<point>v [maxN+5];
vector<pair<int, int>>pene(maxK+1);
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for(int i=0 ; i<k ; i++){
v[left[i]].push_back({i, op[i], height[i]});
v[right[i]+1].push_back({i, -op[i], height[i]});
}
// vector<pair<int, int>>curr;
map<int, int>one, two;
one[-1]++;
two[1e9]++;
for(int i=0 ; i<n ; i++){
int xd=0;
for(point it:v[i]){
if(it.y<0){
if(it.y==-2){
two[it.z]--;
if(two[it.z]==0) two.erase(it.z);
}else{
one[it.z]--;
if(one[it.z]==0) one.erase(it.z);
}
}else{
if(it.y==1) one[it.z]++;
else two[it.z]++;
}
// cout<<i<<" "<<it.x<<" "<<it.y<<"\n";
}
int a=(one.rbegin()->first);
int b=(two.begin()->first);
if(a==-1){
finalHeight[i]=0;
continue;
}
// if(b==-1) b=1e9;
finalHeight[i]=min(a, b);
}
return;
}
# | 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... |