#K81002. Determine the Highest Valid Score

    ID: 35656 Type: Default 1000ms 256MiB

Determine the Highest Valid Score

Determine the Highest Valid Score

You are given the number of participants n, a threshold score t, and a list of scores. Your task is to determine the highest score that is greater than or equal to the threshold t. If no score meets the requirement, output -1.

More formally, if we have a list of scores, you need to select all scores such that

[ score \geq t ]

and then find the maximum among them. If the filtered set is empty, return -1.

For example, given n = 5, t = 50 and scores = [30, 60, 90, 80, 45], the valid scores are [60, 90, 80] and the maximum is 90.

inputFormat

The input is given from stdin and consists of two lines:

  1. The first line contains two integers n (the number of participants) and t (the threshold score).
  2. The second line contains n integers separated by spaces, representing the scores of the participants.

outputFormat

Output a single integer to stdout: the highest score that is greater than or equal to t. If no such score exists, output -1.

## sample
5 50
30 60 90 80 45
90