The Bonelli test

ifnextchar ( ifnextchar (offsettrue(0pt,0pt) offsetfalse ifnextchar
[(0pt,0pt)(0pt,0pt) ifnextchar
[(0pt,0pt)(0pt,0pt)[l](0pt,0pt)(0pt,0pt)[l][] [r][image]

Apart from the Voight-Kampff test, there is a simpler way to identify
repicants: the Boneli test. (It measures the speed of the reflex-arc
response which takes place in the upper ganglia of the spinal column.
Much simpler, indeed…) Since Rick Deckard is falling in love with
Rachael, he will use the Boneli test as an excuse to try to seduce her
(it). Cunning Rick has told Rachael that, to apply the test, he must
measure the blood pressure near her (its) heart!

Rick already took n measures (and yes, he seduced Rachael), but now he
wonders if those measures may have some interest. For every subsequence
of c consecutive measures, Rick only takes into account its maximum
value. Rick wants to know, among the maximums of all those subsequences
(overlapping or not), which is the minimum value m.

For instance, if c = 3, n = 5, and the sequence is 7 4 2 6 8, we have
three subsequences: 7 4 2, 4 2 6, and 2 6 8. Therefore, m = 6 for this
example, corresponding to the middle subsequence.

Input

Input consists of several cases, each with c and n, followed by n
natural numbers. Assume 1 ≤ c ≤ n ≤ 10⁶. A case with c = n = 0 ends the
input.

Output

For every case, print its corresponding m.

Problem information

Author: Marçal Garolera

Generation: 2026-01-25T11:23:43.058Z

© Jutge.org, 2006–2026.
https://jutge.org
