Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_DEPRECATE
- #include <iostream>
- #include <vector>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #define li long long
- using namespace std;
- int main() {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int n, x;
- cin >> n >> x;
- set<int> a;
- int r = -1;
- if (x % 2 == 0) {
- r = x / 2;
- }
- int k = 0;
- for (int i = 0; i < n; i++) {
- int c;
- cin >> c;
- a.insert(c);
- if (c == r) {
- k++;
- }
- }
- if (k > 1) {
- cout << "YES";
- return 0;
- }
- else {
- if (r != -1) {
- a.erase(r);
- }
- }
- for (auto i : a) {
- if (a.find(x - i) != a.end()) {
- cout << "YES";
- return 0;
- }
- }
- cout << "NO";
- }
Advertisement
Add Comment
Please, Sign In to add comment