Canadian Computing Competition: 2015 Stage 1, Senior #2
A school team is trying to assign jerseys numbered to student athletes. The size of each jersey is either small (
S), medium (
M) or large (
Each athlete has requested a specific jersey number and a preferred size. The athletes will not be satisfied with a jersey that is the wrong number or that is smaller than their preferred size. They will be satisfied with a jersey that is their preferred size or larger as long as it is the right number. Two students cannot be given the same jersey.
Your task is to determine the maximum number of requests that can be satisfied.
The first line of input is the integer which is the number of jerseys.
The second line of input is the integer which is the number of athletes.
The next lines are each the character
L. Line gives the size of jersey ().
The last lines are each the character
L followed by a space, followed by an integer. Line () gives the requested size and jersey number for athlete where the athletes are numbered .
For 50% of the test cases, and .
For the remaining 50% of the test cases, and .
The output will consist of a single integer which is the maximum number of requests that can be satisfied.
4 3 M S S L L 3 S 3 L 1
Output for Sample Input
Explanation Sample Output
Jersey cannot be assigned because it is medium and athlete requested large. No athlete requested jersey or . Jersey , can be assigned to athlete , but not athlete .