fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main(){
  6. int n, a[100005];
  7. cin >>n;
  8. for (int i = 1; i <= n; i++){
  9. cin >> a[i];
  10. }
  11. sort(a+1, a+n+1);
  12. for (int i = n; i >= 3; i--){
  13. if (a[i-2]+a[i-1]>a[i]){
  14. cout << "YES";
  15. return 0;
  16. }
  17. }
  18. cout << "NO";
  19. return 0;
  20. }
Success #stdin #stdout 0s 15512KB
stdin
5
1 5 3 2 4
stdout
YES