atcoder#ARC070B. [ABC056D] No Need
[ABC056D] No Need
Score : points
Problem Statement
AtCoDeer the deer has cards with positive integers written on them. The number on the -th card is . Because he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is or greater.
Then, for each card , he judges whether it is unnecessary or not, as follows:
- If, for any good subset of the cards containing card , the set that can be obtained by eliminating card from the subset is also good, card is unnecessary.
- Otherwise, card is NOT unnecessary.
Find the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.
Constraints
- All input values are integers.
Partial Score
- points will be awarded for passing the test set satisfying .
Input
The input is given from Standard Input in the following format:
...
Output
Print the number of the unnecessary cards.
3 6
1 4 3
1
There are two good sets: {} and {}.
Card is only contained in {}, and this set without card , {}, is also good. Thus, card is unnecessary.
For card , a good set {} without card , {}, is not good. Thus, card is NOT unnecessary.
Neither is card for a similar reason, hence the answer is .
5 400
3 1 4 1 5
5
In this case, there is no good set. Therefore, all the cards are unnecessary.
6 20
10 4 3 10 25 2
3