# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1160791 | hackstar | Wall (IOI14_wall) | C++17 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
void buildWall(int n,int k,vector<int>&op,vector<int>&left,vector<int>&right,vector<int>&height,vector<int>&finalHeight){
vector<int>a(n,0);
for (int i=0;i<k;++i){
int l=left[i]-1,r=right[i]-1;
if(op[i]==1){
for(int j=l;j<=r;++j){
a[j]=max(a[j],height[i]);
}
}
else if(op[i]==2){
for(int j=l;j<=r;++j) {
a[j]=min(a[j],height[i]);
}
}
}
for (int i=0;i<n;++i){
finalHeight[i]=a[i];
}
}