PDP-25 (2013) - Camp junior - 1 (fishtank)

View as PDF

Submit solution

Points: 30 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

Problem

We want to place N fish in an aquarium,. Each fish is characterized by its size, which, for simplicity, we represent by a positive natural number. However, as we all know, big fish eat small fish! In our aquarium, this means that a fish with size a eats any other fish with a size (strictly) smaller than a / 2. So, if we put the fish in the aquarium without much thought and leave them alone, after a while, there will probably be much fewer fish left!

Our goal is to find out the maximum amount of fish we can put in the aquarium without them eating each other.

Input

The input will consist of two lines. The first line will contain only one natural number, N.
The second line will contain N positive natural numbers x_1, x_2, ..., x_N, separated in pairs by a single space: the sizes of the fish.

Output

The output should consist of one line containing only one natural number K \le N: the maximum number of fish we can put in the aquarium without any of them being able to eat another.

Constraints

1 \le N \le 1.000.000
1 \le x_i \le 1.000.000.000
Execution time limit: 1 sec.
Memory limit: 16 MB.

Examples of Input - Output
1st

STDIN (fishtank.in)

7
5 9 8 4 2 4 6

STDOUT (fishtank.out)

5

2nd

STDIN (fishtank.in)

3
1 5 10

STDOUT (fishtank.out)

2

3d

STDIN (fishtank.in)

6
5 8 7 7 4 6

STDOUT (fishtank.out)

6

Explanation of the Examples: In each example, a subset of the fish is underlined, representing the maximum possible number of fish that can be placed in the aquarium without them eating each other. This subset has the maximum possible cardinality. Note that there may be other subsets with the same maximum number, for example, in the second example, any fish could be chosen for the aquarium.


Comments

There are no comments at the moment.