N girls

2.4

14 votes
Algorithms, Binary Search, Easy, Searching
Problem

You are given n boxes and the size of the ith box is ai . You can select at most k boxes and change their size to a positive integer.

Select some boxes and paint it with the Red color. These boxes must satisfy the following condition:

  • There must be no 1i, jn such that both i, j boxes are red and aiaj>PQ.

Determine the maximum number of boxes that you can color in Red.

Input format

  • First line: Four integers n, k, P, and Q (1kn2105, 1QP109)
  • Second line: Sequence a1,...,an (1ai109)

Output format

Print the required in a single line. The output must be an integer and display the maximum number of boxes that you can color in Red.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

By changing the second girls's box to 2, we can color the first 3 boxes red.

Editor Image

?