forked from brc-dd/dsa-coursera-assignments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
points_and_segments.cpp
47 lines (47 loc) · 997 Bytes
/
points_and_segments.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
#define int long long
#define all(v) v.begin(), v.end()
#define input(v) \
for (auto &i : v) \
cin >> i
#define decl_read(v, n) \
ints v(n); \
input(v)
#define print(v) \
for (auto &i : v) \
cout << i << ' '
#define pb push_back
#define mp make_pair
#define fir first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> ints;
typedef vector<pii> pairs;
int32_t main() {
int s, p, t, c(0);
cin >> s >> p;
pairs v;
ints points(p);
for (int i(0); i < s; i++) {
cin >> t;
v.pb(mp(t, -1));
cin >> t;
v.pb(mp(t, 1));
}
for (int i(0); i < p; i++) {
cin >> t;
v.pb(mp(t, 0));
points[i] = t;
}
sort(all(v));
map<int, int> dict;
for (auto &i : v)
if (i.se)
c -= i.se;
else
dict[i.fir] = c;
for (auto &i : points)
cout << dict[i] << ' ';
return 0;
}