-
Notifications
You must be signed in to change notification settings - Fork 0
/
loj1088.cpp
87 lines (74 loc) · 1.81 KB
/
loj1088.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
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
84
85
86
87
//{ Template
//{ C-headers
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <cctype>
#include <cassert>
#include <ctime>
//}
//{ C++-headers
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;
//}
//}
//{ Floating-points
#define EPS DBL_EPSILON
#define abs(x) (((x) < 0) ? - (x) : (x))
#define zero(x) (abs (x) < EPS)
#define equal(a,b) (zero ((a) - (b)))
#define PI 2 * acos (0.0)
//}
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define memo(a,v) memset(a,v,sizeof(a))
#define all(a) a.begin(),a.end()
#define INF 1<<29
#define ll long long
#define db double
#define pii pair<int ,int >
#define NL puts("")
#define G getchar()
//}
int fst[100000+10],sec[100000+10],ans[100000+10];
vector<ll>num;
int main () {
int t,Case=1,i,n,q;
ll x;
scanf("%d",&t);
while(t--)
{
num.clear();
scanf("%d %d",&n,&q);
for(i=0;i<n;i++)
{
scanf("%lld",&x);
num.push_back(x);
}
vector<ll>::iterator low,high;
for(i=0;i<q;i++)
{
scanf("%d %d",&fst[i],&sec[i]);
low = lower_bound(num.begin(),num.end(),fst[i]);
high = upper_bound(num.begin(),num.end(),sec[i]);
ans[i] = (int)((high-num.begin())-(low-num.begin()));
}
printf("Case %d:\n",Case++);
for(i=0;i<q;i++)
printf("%d\n",ans[i]);
}
return 0;
}