#B3803. Maximizing Final Rating
Maximizing Final Rating
Maximizing Final Rating
Little T has acquired precognition ability, enabling him to foresee his performance scores for the next competitions. The performance score update is defined as follows:
If Little T’s current rating before a competition is and his performance score is , then his rating after the competition becomes
where denotes the floor function (e.g., , ).
Little T has one account with an initial rating of . He can choose to participate in at most out of the upcoming competitions. The competitions are of two types:
- division1: Little T can participate regardless his current rating.
- division2: Little T can only participate if his current rating < 1900 (before the contest).
inputFormat
The first line contains three integers , , and , where is the number of upcoming competitions, is the maximum number of competitions Little T may participate in, and is his initial rating. Each of the next lines contains a string and an integer representing the competition type and the performance score . The string is either "division1" or "division2".
outputFormat
Output a single integer, the maximum final rating Little T can achieve after following an optimal strategy.
sample
3 2 1800
division2 1820
division1 2000
division2 1900
1862
</p>