26 lines
439 B
C++
26 lines
439 B
C++
|
#include <bits/stdc++.h>
|
||
|
using namespace std;
|
||
|
|
||
|
int main() {
|
||
|
int sum = 0;
|
||
|
int n;
|
||
|
cin >> n;
|
||
|
vector<int> coins(n);
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
cin >> coins[i];
|
||
|
sum += coins[i];
|
||
|
|
||
|
}
|
||
|
|
||
|
sort(coins.begin(), coins.end());
|
||
|
reverse(coins.begin(), coins.end());
|
||
|
|
||
|
int ammount = 0, out = 0;
|
||
|
while (ammount <= sum/2) {
|
||
|
ammount += coins[out];
|
||
|
out++;
|
||
|
}
|
||
|
cout<<out;
|
||
|
|
||
|
|
||
|
}
|