#include <vector>
#include "optimization.h"
using namespace std;
int main() {
int n = readInt(), m = readInt();
vector<int> l(n), r(n);
vector<pair<int, int>> points(m);
for (int i = 0; i < n; ++i) {
l[i] = readInt();
r[i] = readInt();
if(l[i] > r[i]) {
swap(l[i], r[i]);
}
}
for (int i = 0; i < m; ++i) {
points[i] = {readInt(), i};
}
sort(l.begin(), l.end());
sort(r.begin(), r.end());
sort(points.begin(), points.end());
int curL = -1, curR = -1;
vector<int> ans(m);
for (auto po : points) {
int p = po.first;
while(curL < n - 1 && l[curL + 1] <= p) {
curL++;
}
while(curR < n - 1 && r[curR + 1] < p) {
curR++;
}
ans[po.second] = curL - curR;
}
for(auto a : ans) {
writeInt(a, ' ');
}
writeChar('\n');
return 0;
}
Comments