Choose the smallest number of coins whose total value is strictly greater than the sum of the remaining coins.
You are given coins, each with a positive value. Your task is to pick the minimum number of coins such that the sum of the picked coins is strictly greater than the sum of all remaining coins.
A valid choice always exists if you keep taking the largest-value coins first. Return the minimum number of coins needed.
Input Format
- The first line contains an integer .
- The second line contains integers representing the values of the coins.
Output Format
Print a single integer: the minimum number of coins required.
Constraints
Example 1
Input
2 3 3
Output
2
Explanation
If both coins have value 3, one coin is not strictly greater than the other coin. We need both coins, so the answer is 2.
Example 2
Input
4 3 3 3 3
Output
3
Explanation
Take any three coins: their sum is 9, which is strictly greater than the remaining coin sum 3.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.