cswork / OAOpen practice workspace

AmazonOA #149

Find Ideal Days

Estimated MediumJudge-ready

Topics (AI-labelled)Prefix & RangesDP Basics

A day is ideal only if the window adjacent relations before it, up to and including that day, are non-increasing, the window adjacent relations after it are non-decreasing, and the days on both sides exist. Output all such 1-based days. At least one ideal day is guaranteed.

Input

The first line contains n window, and the second line contains n forecast values. The source has 1≤window≤n≤200000, values in 0..10^9, and guarantees at least one solution, so the combined conditions actually require 2window+1≤n.

Output

Output all qualifying 1-based days in ascending order.

Example 1

Input:

6 2
3 2 2 2 3 4

Output:

3 4

Example 2

Input:

5 1
1 0 1 0 1

Output:

2 4

Example 3

Input:

10 3
1 1 1 1 1 1 1 1 1 1

Output:

4 5 6 7

Example notes

Example 1: days 3 and 4 each have two steps before and after that satisfy the relations, so output 3 4. Example 2: the two valleys are days 2 and 4. Example 3: all relations are equal, so days 4, 5, 6 and 7, which have three days on each side, can all be chosen.

Editorial

Loading solution…