#C11667. Maximum Teams Formation with Skill Ratio
Maximum Teams Formation with Skill Ratio
Maximum Teams Formation with Skill Ratio
You are given n participants, each with a skill level. Your task is to form teams with the following conditions:
- Each team requires exactly x primary-level participants and y advanced-level participants.
- An advanced-level participant must have a skill level that is exactly \(m\) times the skill level of a chosen primary-level participant.
- You can form at most k teams.
Determine the maximum number of teams that can be formed under these constraints.
Note: A participant can only be used once. The matching is done in a greedy manner by iterating over available skill levels in ascending order.
inputFormat
The input is given via standard input (stdin) in the following format:
n x y m k s1 s2 ... sn
where:
- n is the total number of participants.
- x is the number of primary-level participants required per team.
- y is the number of advanced-level participants required per team.
- m is the ratio such that an advanced participant's skill level must be \(m\) times that of the primary participant's skill level.
- k is the maximum number of teams you can form.
- s1, s2, ..., sn are the skill levels of the participants.
outputFormat
Output a single integer via standard output (stdout) representing the maximum number of teams that can be formed.
## sample12 2 2 2 3
1 1 2 2 2 2 2 3 3 4 6 6
2