-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathback_10815.cpp
More file actions
57 lines (51 loc) · 885 Bytes
/
back_10815.cpp
File metadata and controls
57 lines (51 loc) · 885 Bytes
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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector <int> v;
void bs(int b)
{
int start = 0;
int end = v.size() - 1;
int mid = (start + end) / 2;
while (end - start >= 0)
{
mid = (start + end) / 2;
if (v[mid] == b)
{
printf("1\n");
return ;
}
else if (v[mid] > b)
{
end = mid - 1;
}
else
start = mid + 1;
}
printf("0\n");
return ;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int a, b;
cin >> a;
for (int i = 0; i < a; i++)
{
int t;
cin >> t;
v.push_back(t);
}
sort(v.begin(),v.end());
cin >> b;
for (int i =0; i<b; i++)
{
int t;
cin >> t;
bs(t);
}
return 0;
}