#K81522. Consecutive Books with High Average Score
Consecutive Books with High Average Score
Consecutive Books with High Average Score
You are given n books and an array of integer scores representing the advanced scores of each book. Your task is to determine whether there exists a sequence of three consecutive books such that their average score is at least a given threshold t.
Formally, for an index i (1 ≤ i ≤ n-2), let the scores be \(s_i, s_{i+1}, s_{i+2}\). Their average is computed as \[ \text{avg} = \frac{s_i + s_{i+1} + s_{i+2}}{3} \] You need to check if \(\text{avg} \ge t\). If such a triplet exists, output "YES" on the first line and on the next line, output the 1-indexed positions of the three consecutive books. Otherwise, output "NO".
Make sure your solution reads from standard input and writes to standard output.
inputFormat
The first line contains an integer n denoting the number of books.
The second line contains n space-separated integers representing the scores of the books.
The third line contains an integer t representing the threshold average score.
outputFormat
If there exists a group of three consecutive books with an average score greater than or equal to t, output "YES" on the first line and on the second line output the 1-indexed positions of these three books separated by spaces. Otherwise, output "NO".
## sample5
30 40 35 50 45
40
YES
2 3 4
</p>