-
Notifications
You must be signed in to change notification settings - Fork 22
/
elements in the rage
47 lines (38 loc) · 1006 Bytes
/
elements in the rage
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
/*
An array containing positive elements is given. ‘A’ and ‘B’ are two numbers defining a range. Write a function to check if the array
contains all elements in the given range.
Input:
The first line of input contains an integer T denoting the number of test cases. Each test case contains space separated integers n, A
and B which denotes the number of elements in the array a[] and the range [A, B]. Next line contains space separated n elements in the
array a[].
Output:
Print "Yes" if all the elements in the range are present else print "No".
Constraints:
1<=T<=100
1<=n<=1000
1<= A < B<=1000
1<=a[i]<=1000
Example:
Input:
1
7 2 5
1 4 5 2 7 8 3
Output:
Yes
*/
#include <bits/stdc++.h>
#define f for(int i=0; i<n; i++)
#define ll long long int
using namespace std;
int main() {
int t; cin>>t; while(t--){
int n,a,b,c=0; cin>>n>>a>>b;
ll x;
f{
cin>>x;
if(x>=a && x<=b) c++;
}
c==(b-a)+1 ? cout<<"Yes\n" : cout<<"No\n";
}
return 0;
}