Under construction

Still being built. Things may change

Not the Longest Increasing Subsequence

Time limit2sMemory limit512 MB

Summary
Given an array of n integers from 1 to k, find the fewest elements to delete so that its longest increasing subsequence has length less than k, and list their indices.
Level

Hard8 of 10

Topics
Dynamic programming, Greedy, Array
Solved
No attempts yet

Problem

You have an array of nn integers. Each element aia_i is between 11 and kk. What is the smallest number of elements that must be removed from the array so that its longest increasing subsequence has length less than kk?

Input

The first line contains two integers nn and kk (1≤n≤1061 \le n \le 10^6, 1≤k≤n1 \le k \le n), the length of the array and the upper bound for its elements. The second line contains nn integers aia_i (1≤ai≤k1 \le a_i \le k), the elements of the array.

Output

In the first line, output an integer mm, the number of elements to remove. In the second line, output mm integers, the indices of the removed elements. The indices are numbered from 11 to nn.

Examples3

  1. Example 1

    Input
    3 2
    1 2 2
    
    Expected output
    1
    1
    
  2. Example 2

    Input
    2 2
    2 1
    
    Expected output
    0
    
  3. Example 3

    Input
    8 3
    1 2 2 1 1 3 2 3
    
    Expected output
    2
    1 7