cswork / OAOpen practice workspace

AmazonOA #226

Get Minimum Boxes

Estimated MediumJudge-ready

Topics (AI-labelled)Two PointersIn-place Arrays

Unload some boxes, keeping at least one, so that the kept sizes satisfy max≤capacity*min. Find the minimum number of boxes unloaded.

Input

The first line contains n capacity; the second line contains the sizes. The original text gives 1≤n≤100000 and 1≤size≤500000; the range of capacity is missing, and this site specifies a positive integer 1≤capacity≤10^9.

Output

Output a single integer, the answer.

Example 1

Input:

4 3
1 2 3 9

Output:

1

Example 2

Input:

3 1
2 2 3

Output:

1

Example 3

Input:

1 1
500000

Output:

0

Example notes

The answers are 1, 1 and 0; a ratio exactly equal to the limit is also valid.

Editorial

Loading solution…