fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #define ll long long
  5.  
  6. int cmp(const void *a, const void *b){
  7. int *p1 = (int*)a;
  8. int *p2 = (int*)b;
  9. return *p2 - *p1;
  10. }
  11.  
  12. void solve(){
  13. int n; scanf("%d" , &n);
  14. int a[n];
  15. for(int i=0; i <n; i++){
  16. scanf("%d", a+i);
  17. }
  18. qsort(a, n, sizeof(int), cmp); // sap xep tu lon den be
  19. int s = 0; // bien s luu tong can nang hien tai
  20. for(int i=n-1 ; i >= 0; i--){
  21. if(a[i] < s){
  22. printf("No");
  23. return;
  24. }
  25. s += a[i];
  26. }
  27. printf("YES");
  28. }
  29.  
  30. int main(){
  31. int typetest = 0;
  32. if(typetest){
  33. int t; scanf("%d", &t);
  34. while(t--){
  35. solve();
  36. }
  37. }else solve();
  38. }
Success #stdin #stdout 0s 5224KB
stdin
Standard input is empty
stdout
YES