Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int s = 0, sum = 0, n, a[113];
  6. cin » n;
  7. for (int i = 0; i < n; i++)
  8. {
  9. cin » a[i];
  10. }
  11. for (int i = 1; i <= n; i++)
  12. {
  13. for (int j = i - 1; j < n; j++)
  14. {
  15. if (a[j] > a[i])
  16. {
  17. a[j] = a[j] + a[i];
  18. a[i] = a[j] - a[i];
  19. a[j] = a[j] - a[i];
  20. }
  21. }
  22. }
  23. int ans = 1;
  24. for (int i = n; i >= 0; i = i - 1)
  25. {
  26. s = s + a[i];
  27. ans++;
  28. for (int j = 0; j < i; j++)
  29. {
  30. sum = sum + a[j];
  31. }
  32. if (s > sum)
  33. {
  34. break;
  35. }
  36. else
  37. {
  38. sum = 0;
  39. }
  40. }
  41. cout « ans;
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement