atcoder#AGC011B. [AGC011B] Colorful Creatures
[AGC011B] Colorful Creatures
Score : points
Problem Statement
Snuke found strange creatures. Each creature has a fixed color and size. The color and size of the -th creature are represented by and , respectively.
Every creature can absorb another creature whose size is at most twice the size of itself. When a creature of size and color absorbs another creature of size and color (), they will merge into one creature of size and color . Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other.
Snuke has been watching these creatures merge over and over and ultimately become one creature. Find the number of the possible colors of this creature.
Constraints
- is an integer.
Input
The input is given from Standard Input in the following format:
…
Output
Print the number of the possible colors of the last remaining creature after the creatures repeatedly merge and ultimately become one creature.
3
3 1 4
2
The possible colors of the last remaining creature are colors and . For example, when the creature of color absorbs the creature of color , then the creature of color absorbs the creature of color , the color of the last remaining creature will be color .
5
1 1 1 1 1
5
There may be multiple creatures of the same size.
6
40 1 30 2 7 20
4