cswork / OA打开练习工作台

TradeDeskOA #4

Buddies Greater than Target

简单可在线判题

考点(AI 标注)原地数组

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.

输入格式

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 the first valid start i, or −1 if there is none. Do not return the last start or the number of qualifying starts.

样例 1

输入:

6 1
0 1 4 3 2 5

输出:

2

样例 2

输入:

5 42
-9 95 94 4 5

输出:

-1

样例 3

输入:

3 -1000
-999 -999 -999

输出:

0

样例说明

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.