Advertisement
LEGEND2004

Mahmoud and a Triangle

Jul 13th, 2023
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6.  
  7. signed main()
  8. {
  9.     int n;
  10.     cin >> n;
  11.     vector<int> v(n);
  12.     for(int i = 0; i < n; i++){
  13.         cin >> v[i];
  14.     }
  15.     sort(v.begin() , v.end());
  16.     bool ok = false;
  17.    
  18.     for(int i = 1; i < (n - 1); i++){
  19.         int a = v[i - 1] , b = v[i] , c = v[i + 1];
  20.         if((c < (a + b)) && (c > (b - a))){
  21.             ok = true;
  22.             break;
  23.         }
  24.     }
  25.     cout << (ok ? "YES" : "NO") << endl;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement