#C9975. Winning Challenges
Winning Challenges
Winning Challenges
You are given an integer M which represents the number of challengers, and two thresholds D1 and D2. In addition, an array of M scores is provided. For every pair of consecutive scores si and si+1, a winning challenge is counted if the absolute difference satisfies one of the following conditions:
\( |s_i - s_{i+1}| \le D_1 \quad \text{or} \quad |s_i - s_{i+1}| = D_2 \)
Your task is to compute the maximum number of winning challenges that can be achieved by examining every adjacent pair in the given list.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains three space-separated integers:
M
(the number of scores),D1
(the absolute difference threshold), andD2
(the exact difference threshold). - The second line contains
M
space-separated integers denoting the scores.
outputFormat
Output a single integer to standard output (stdout) representing the maximum number of winning challenges, i.e., the count of adjacent pairs satisfying the condition.
## sample6 3 5
10 7 12 15 3 25
3