#K2636. Quest Completion Challenge
Quest Completion Challenge
Quest Completion Challenge
In this problem, you are given a list of quests and a list of players. Each quest has a difficulty level and each player has a skill level. A quest can be completed if you can form a group of players (with group size between 2 and 5) such that the sum of the players' skills is at least as large as the product of the quest's difficulty and the group size. In other words, for a group of n players with skills (s_1, s_2, \dots, s_n) to complete a quest with difficulty (d), the following condition must be satisfied:
Each player can participate in at most one quest. Your task is to determine the maximum number of quests that can be completed.
inputFormat
The input is read from standard input (stdin). The first line contains two integers Q and P, representing the number of quests and the number of players respectively. Each of the next Q lines contains a quest ID (a string) and an integer indicating the quest's difficulty. The last line contains P integers representing the skill levels of the players.
outputFormat
Output a single integer to standard output (stdout) representing the maximum number of quests that can be completed.## sample
5 8
Q1 5
Q2 7
Q3 6
Q4 4
Q5 8
6 8 5 7 5 4 2 9
3