anon20016

M

Nov 16th, 2019
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #define _CRT_SECURE_NO_DEPRECATE
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. #include <string>
  6. #include <map>
  7. #include <set>
  8. #include <algorithm>
  9.  
  10. #define li long long
  11.  
  12. using namespace std;
  13.  
  14. int main() {
  15. freopen("input.txt", "r", stdin);
  16. freopen("output.txt", "w", stdout);
  17.  
  18. int n, x;
  19. cin >> n >> x;
  20. set<int> a;
  21. int r = -1;
  22. if (x % 2 == 0) {
  23. r = x / 2;
  24. }
  25. int k = 0;
  26.  
  27. for (int i = 0; i < n; i++) {
  28. int c;
  29. cin >> c;
  30. a.insert(c);
  31. if (c == r) {
  32. k++;
  33. }
  34. }
  35. if (k > 1) {
  36. cout << "YES";
  37. return 0;
  38. }
  39. else {
  40. if (r != -1) {
  41. a.erase(r);
  42. }
  43. }
  44. for (auto i : a) {
  45. if (a.find(x - i) != a.end()) {
  46. cout << "YES";
  47. return 0;
  48. }
  49. }
  50. cout << "NO";
  51. }
Advertisement
Add Comment
Please, Sign In to add comment