Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int s = 0, sum = 0, n, a[113];
- cin » n;
- for (int i = 0; i < n; i++)
- {
- cin » a[i];
- }
- for (int i = 1; i <= n; i++)
- {
- for (int j = i - 1; j < n; j++)
- {
- if (a[j] > a[i])
- {
- a[j] = a[j] + a[i];
- a[i] = a[j] - a[i];
- a[j] = a[j] - a[i];
- }
- }
- }
- int ans = 1;
- for (int i = n; i >= 0; i = i - 1)
- {
- s = s + a[i];
- ans++;
- for (int j = 0; j < i; j++)
- {
- sum = sum + a[j];
- }
- if (s > sum)
- {
- break;
- }
- else
- {
- sum = 0;
- }
- }
- cout « ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement