fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a,b,equ=0,koin=0;
  6. vector<int>v;
  7.  
  8. cin >> a;
  9.  
  10. while(a--){
  11. cin >> b;
  12. v.push_back(b);
  13. equ+=b;
  14. }
  15. equ=equ/2;
  16.  
  17. sort(v.rbegin(),v.rend());
  18.  
  19. for(int i=0;i<v.size();i++){
  20. equ=equ-v[i];
  21. koin++;
  22. if(equ<0){
  23. break;
  24. }
  25. }
  26. cout << koin << endl;
  27. }
Success #stdin #stdout 0s 4344KB
stdin
2
3 3
stdout
2