#include "wall.h"
#include <iostream>
#include <vector>
#include <set>
#include <queue>
using namespace std;
const int MAXN = 2E6;
const int MAXH = 1E6 + 10;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
vector<pair<int, pair<int,int>>> fp;
multiset<int> big;
multiset<int> small;
for (int i = 0; i < k; i++) {
if (op[i] == 1) {
fp.push_back({left[i],{height[i],0}});
fp.push_back({right[i]+1,{height[i],1}});
continue;
}
fp.push_back({left[i],{height[i],2}});
fp.push_back({right[i]+1,{height[i],3}});
}
sort(fp.begin(),fp.end());
int j = 0;
for (int i = 0; i < n; i++) {
while (fp[j].first <= i && j < fp.size()) {
auto [val, type] = fp[j].second;
if (type == 0) big.insert(val);
else if (type == 1) big.erase(val);
else if (type == 2) small.insert(val);
else if (type == 3) small.erase(val);
j++;
}
if (!big.empty())
finalHeight[i] = *prev(big.end());
if (!small.empty())
finalHeight[i] = min(finalHeight[i], *small.begin());
}
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... |