Under construction

Still being built. Things may change

Longest Increasing Subsequence K

Time limit0.25sMemory limit512 MB

Summary
Given a sequence of N integers and K, find the K-th longest increasing subsequence in lexicographic order of index sequences, or print -1 if fewer than K exist.
Level

Hard8 of 10

Topics
Dynamic programming, Binary search, Combinatorics
Solved
No attempts yet

Problem

Let LL be the length of the longest increasing subsequence (LIS) of a sequence of NN integers A1,A2,…,ANA_1, A_2, \ldots, A_N. There can be one or more LISes. Sort all LISes in lexicographic order and find the KK-th sequence.

Two LISes Ai1,…,AiLA_{i_1}, \ldots, A_{i_L} and Aj1,…,AjLA_{j_1}, \ldots, A_{j_L} are different if there is at least one kk with ik≠jki_k \ne j_k.

Input

The first line contains NN and KK. The second line contains A1,A2,…,ANA_1, A_2, \ldots, A_N separated by spaces.

Output

Print the KK-th LIS, with its elements separated by spaces. If the KK-th LIS does not exist, print -1.

Constraints

  • 1≤N≤1051 \le N \le 10^5
  • 1≤K≤10181 \le K \le 10^{18}
  • 1≤Ai≤N1 \le A_i \le N

Examples5

  1. Example 1

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

    Input
    5 2
    1 4 2 3 5
    
    Expected output
    -1
    
  3. Example 3

    Input
    6 1
    2 1 4 1 3 5
    
    Expected output
    1 3 5
    
  4. Example 4

    Input
    6 2
    2 1 4 1 3 5
    
    Expected output
    1 3 5
    
  5. Example 5

    Input
    6 3
    2 1 4 1 3 5
    
    Expected output
    1 4 5