Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- //#define DEBUG
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- int *a = new int[n];
- int s = 0;
- for(int i = 0; i < n; i++)
- {
- cin>>a[i];
- s+=a[i];
- }
- sort(a,a+n);
- int count = 0,s1=0;
- for(int i = n - 1; s >= s1; i--)
- {
- s1+=a[i];
- s-=a[i];
- count++;
- }
- cout<<count<<endl;
- #ifdef DEBUG
- cout<<s<<" "<<s1<<endl;
- system("pause");
- #endif
- delete[] a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement