-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathThe_Playboy_Chimp.cpp
More file actions
81 lines (70 loc) · 911 Bytes
/
The_Playboy_Chimp.cpp
File metadata and controls
81 lines (70 loc) · 911 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
void solve1();
int main()
{
solve1();
return 0;
}
void solve1()
{
long long t, n, q;
long long ara[100008];
cin >> t;
for(long long i = 0; i < t; i++)
{
cin >> ara[i];
}
cin >> q;
while(q--)
{
cin >> n;
//cout << n << endl;
int f1 = 0, f2 = 0, f = 0;
for(int i = 0; i < t; i++)
{
//cout << ara[i] << endl;
if(n <= ara[i])
{
f = 1;
for(int j = i; j >= 0; j--)
{
if(n > ara[j])
{
cout << ara[j];
f1 = 1;
break;
}
}
if(f1 == 0)
{
cout << "X ";
}
else
{
cout << " ";
}
for(int j = i; j < t; j++)
{
if(n < ara[j])
{
cout << ara[j];
f2 = 1;
break;
}
}
if(f2 == 0)
{
cout << "X";
}
}
if(f == 1)
{
cout << endl;
break;
}
}
}
}