add1ctus

Среќни луѓе

Mar 6th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n;
  9. scanf("%d",&n);
  10. long long arr[n];
  11.  
  12. for(int i = 0 ; i < n ; ++i)
  13. scanf("%I64d",&arr[i]);
  14.  
  15. sort(arr,arr+n);
  16. long long sum = 0;
  17. int result = 0;
  18. for(int i = 0 ; i < n ; ++i)
  19. {
  20. // printf("Checking %lld\n",arr[i]);
  21. if(sum <= arr[i])
  22. {
  23. sum += arr[i];
  24. ++result;
  25. // printf("%lld!!!\n",arr[i]);
  26. }
  27. }
  28. printf("%d",result);
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment