#P14815. [ICPC 2023 Yokohama R] Rank Promotion
[ICPC 2023 Yokohama R] Rank Promotion
题目描述
Quiz Solver is a popular online computer game. Each time a player opens the mobile application of the game, a new quiz is displayed. The player submits an answer to the quiz, and then it is judged either as correct or incorrect, which is accumulated in the database. When the player shows high accuracy for a number of quizzes, the rank of the player in the game is promoted.
Player ranks are non-negative integers, and each player starts the game at the rank 0. The player will be promoted to the next rank when the player achieves a high ratio of correct answers during a sufficiently long sequence of quizzes. More precisely, the rank promotion system is defined by two parameters: an integer , and a rational number . After finishing the -th quiz, the player’s rank is immediately incremented by one if there exists an integer satisfying the following conditions.
- .
- The player was already at the current rank before starting the -th quiz.
- The ratio of correct answers of the quizzes from the -th through the -th is higher than or equal to .
Otherwise, the rank stays the same.
One day, the administrator of Quiz Solver realized that the rank data of the players were lost due to a database failure. Luckily, the log of quiz solving records was completely secured without any damages. Your task is to recompute the rank of each player from the solving records for the player.
输入格式
The input consists of a single test case in the following format.
$$\begin{aligned} &n\ c\ p\ q \\ &S_1 \cdots S_n \end{aligned}$$The first line consists of four integers satisfying the following constraints: , , and . The first integer is the number of quizzes answered by a single player. The meanings of the parameters , , and are described in the problem statement.
is a string describing the quiz solving records of the player. Each is either Y meaning that the player’s answer for the -th quiz was correct, or N meaning incorrect.
输出格式
Output the final rank of the player after finishing the -th quiz in one line.
12 4 4 7
YYYNYYNNNYYN
2
10 1 1 1
YNYNYNYNYN
5
17 5 250000 500000
YYYYYYYYYYYYYYYYY
3
8 3 2 3
YNNYYYYN
2
提示
In Sample Input 1, the player is promoted to the rank 1 after finishing the fourth quiz, because the ratio of the correct answers is higher than . Note that, the promotion didn’t happen at the third quiz because only three quizzes had been answered, which is less than . Then, after the eleventh quiz, the player is promoted to the rank 2.
:::align{center}

Figure B.1. The timings of rank promotions of Sample Input 1 :::