File size: 1,359 Bytes
c4b0eef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
****************************************************************
****************************************************************
-> Coded by Stavros Chryselis				   
-> Visit my github for more solved problems over multiple sites 
-> https://github.com/StavrosChryselis			  
-> Feel free to email me at stavrikios@gmail.com	
****************************************************************
****************************************************************
*/

#include <string.h>
#include <stdio.h>
 
using namespace std;
 
class BITPQ
{
private:
	int tree[1000007];
	int N;
 
public:
	BITPQ(int n)
	{
		N = n;
		memset(tree, 0, sizeof(tree));
	}
 
	inline void point_update(int pos, int val)
	{
		for (; pos <= N; pos += pos&(-pos))
			tree[pos] += val;
	}
 
	inline void range_update(int i, int j, int val)
	{
		point_update(i, val);
		point_update(j + 1, -val);
	}
 
	inline int point_query(int pos)
	{
		int sum = 0;
 
		for (; pos > 0; pos -= pos&(-pos))
			sum += tree[pos];
 
		return sum;
	}
};
 
BITPQ tree(1000006);
int N, M, L;
 
inline void init()
{
	scanf("%d %d %d", &N, &M, &L);
}
 
int main()
{
	int f, s;
 
//	freopen("input.txt", "r", stdin);
 
	init();
 
	while (N--)
	{
		scanf("%d %d", &f, &s);
		tree.range_update(f + 1, s + 1, 1);
	}
 
	while (M--)
	{
		scanf("%d", &f);
		printf("%d\n", tree.point_query(f + 1));
	}
 
	return 0;
}