-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10611.cpp
More file actions
31 lines (30 loc) · 712 Bytes
/
10611.cpp
File metadata and controls
31 lines (30 loc) · 712 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
#include <bits/stdc++.h>
using namespace std;
int main() {
long k;
vector<long> v;
vector<long>::iterator low, high;
int tc, i, j, q, n, l;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%ld", &k);
v.push_back(k);
}
scanf("%d", &q);
for (i = 0; i < q; i++) {
scanf("%ld", &k);
low = lower_bound(v.begin(), v.end(), k);
high = upper_bound(v.begin(), v.end(), k);
j = low - v.begin() - 1;
l = high - v.begin();
if (j >= 0)
printf("%d ", v[j]);
else
printf("X ");
if (l < n)
printf("%d\n", v[l]);
else
printf("X\n");
}
return 0;
}