#K61512. Find the Secret Number

    ID: 31326 Type: Default 1000ms 256MiB

Find the Secret Number

Find the Secret Number

You are given a series of guesses and responses about a secret number. The secret number is known to be an integer in the range \(1 \leq x \leq 10^6\). For each guess, the response provided can be one of the following:

  • High: The secret number is less than the given guess.
  • Low: The secret number is greater than the given guess.
  • Correct: The guess is exactly the secret number.

Your task is to determine the smallest possible secret number that is consistent with all the responses. If any guess has a "Correct" response, then that guess is the secret number. Otherwise, after adjusting the possible range from the responses, output the lower bound of the range.

inputFormat

The input is read from stdin and consists of multiple lines:

  1. The first line contains an integer n, the number of guesses.
  2. Each of the following n lines contains an integer and a string separated by space. The integer represents the guessed number, and the string is one of "High", "Low", or "Correct".

outputFormat

Output to stdout a single integer, which is the smallest possible secret number consistent with the provided responses.

## sample
3
500000 High
250000 Low
300000 Correct
300000