fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define endl "\n"
  4. // #define int long long
  5.  
  6.  
  7.  
  8. void solve()
  9. {
  10. int n;
  11. cin >> n;
  12. map<int,int> mp;
  13. vector<int> v;
  14. for(int i = 0; i < n; i++)
  15. {
  16. int x;
  17. cin >> x;
  18. if(mp.count(x) == 0) v.push_back(x);
  19. mp[x]++;
  20. }
  21.  
  22.  
  23. if(mp[0] >= 3)
  24. {
  25. cout << "YES" << endl;
  26. return;
  27. }
  28.  
  29. for(auto [x,y]: mp)
  30. {
  31. if(mp.count(-x) && mp.count(0))
  32. {
  33. cout << "YES" << endl;
  34. return;
  35. }
  36. }
  37.  
  38. n = v.size();
  39. for(int i = 0; i < n; i++)
  40. {
  41. for(int j = i+1; j < n; j++)
  42. {
  43. int k = v[i]+v[j];
  44. if(mp.count(-k))
  45. {
  46. if(v[i] != -k && v[j] != -k)
  47. {
  48. cout << "YES" << endl;
  49. return;
  50. }
  51.  
  52. if(v[i] == -k)
  53. {
  54. if(mp[-k] > 1)
  55. {
  56. cout << "YES" << endl;
  57. return;
  58. }
  59. }else if(v[j] == -k)
  60. {
  61. if(mp[-k] > 1)
  62. {
  63. cout << "YES" << endl;
  64. return;
  65. }
  66. }
  67. }
  68. }
  69. }
  70.  
  71. cout << "NO" << endl;
  72.  
  73.  
  74.  
  75. }
  76.  
  77. int32_t main()
  78. {
  79. // Bismillah
  80. int t = 1;
  81. // cin >> t;
  82. while(t--) solve();
  83. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
YES