Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
2,577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. bool check(int a,int b,int c)
  5. {
  6.     int tmp[]={a,b,c};
  7.     sort(tmp,tmp+3);
  8.     return (tmp[0]+tmp[1]>tmp[2]);
  9. }
  10. int main()
  11. {
  12.     int n;
  13.     cin >> n;
  14.     if (n>=45)
  15.     cout << "YES";
  16.     else
  17.     {
  18.         int arr[n];
  19.         for (int i=0;i<n;i++)
  20.         cin >> arr[i];
  21.         for (int i=0;i<n;i++)
  22.         {
  23.             for (int x=i+1;x<n;x++)
  24.             {
  25.                 for (int j=x+1;j<n;j++)
  26.                 {
  27.                     if (check(arr[i],arr[x],arr[j]))
  28.                     {
  29.                         cout << "YES";
  30.                         return 0;
  31.                     }
  32.                 }
  33.             }
  34.         }
  35.         cout << "NO";
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement