cswork / OAOpen practice workspace

TradeDeskOA #4

Buddies Greater than Target

EasyJudge-ready

Topics (AI-labelled)In-place Arrays

Given an integer array numbers and an integer threshold, find the smallest 0-based index i such that numbers[i], numbers[i+1], and numbers[i+2] are all strictly greater than threshold. Return −1 if no such triple exists. The three positions must be consecutive, and a value equal to the threshold does not qualify.

Input

The first line contains n threshold, and the second line contains the n array values. 3≤n≤1000, −1000≤numbers[i]≤1000, −1000≤threshold≤1000. The original TradeDesk raw text has no numeric ranges; this site adopts the complete ranges given by the same problem in TikTok OCR060/061, whose task, complete original example, and window-by-window explanation are consistent, and discloses this source explicitly.

Output

Output the first valid start i, or −1 if there is none. Do not return the last start or the number of qualifying starts.

Example 1

Input:

6 1
0 1 4 3 2 5

Output:

2

Example 2

Input:

5 42
-9 95 94 4 5

Output:

-1

Example 3

Input:

3 -1000
-999 -999 -999

Output:

0

Example notes

The first example keeps TradeDesk's original input [0,1,4,3,2,5], threshold=1, and answer 2. For i=1, the original explanation says only 4 exceeds 1, overlooking 3; the correct reason is that in the triple [1,4,3], 1 is not strictly greater than 1, so it still cannot be chosen. The second example [-9,95,94,4,5] with threshold=42 comes from the same problem in TikTok OCR060 and outputs −1. three values of −999 are all strictly greater than −1000, so the output is 0.

Editorial

Loading solution…