-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1016.cpp
More file actions
47 lines (45 loc) · 819 Bytes
/
Copy path1016.cpp
File metadata and controls
47 lines (45 loc) · 819 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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int m, n, x;
cin >> m;
while (m--) {
cin >> n;
cin >> x;
vector<int>h(n, 0);
vector<int>h_(n, 0);
for (int i = 0; i < n; i++) {
cin >> h[i];
h_[i] = x - h[i];
}
unique(h.begin(), h.end());
unique(h_.begin(), h_.end());
for (int i = 0; i < h.size(); i++) {
cout << h[i] << " ";
}
cout << endl;
for (int i = 0; i < h.size(); i++) {
cout << h_[i] << " ";
}
cout << endl;
sort(h.begin(), h.end());
sort(h_.begin(), h_.end());
int i = 0;
int j = 0;
while (i < n && j < n) {
if (h[i] < h[j])
i++;
else if (h[i] > h[j])
j++;
else if (h[i] == h[j]) {
cout << "yes" << endl;
break;
}
}
if (i == n || j == n)
cout << "no" << endl;
}
return 0;
}