This page is still under construction.

Parts of this page are still being built. What you see may change.

Acowdemia I

Interview

Time limit1sMemory limit512 MB

Summary
Given N papers with citation counts and a budget of L extra citations (each paper cited at most once), find the maximum achievable h-index.
Level

Medium5 of 10

Topics
Sorting, Greedy, Binary search, Array
Solved
No attempts yet

Problem

Bessie the cow has enrolled in a computer science PhD program, driven by her love of computer science and also the allure of one day becoming "Dr. Bessie". Having worked for some time on her academic research, she has now published NN papers (1≤N≤1051 \leq N \leq 10^5), and her ii-th paper has accumulated c_ic\_i citations (0≤c_i≤1050 \leq c\_i \leq 10^5) from other papers in the research literature.

Bessie has heard that an academic's success can be measured by their hh-index. The hh-index is the largest number hh such that the researcher has at least hh papers each with at least hh citations. For example, a researcher with 44 papers and respective citation counts (1,100,2,3)(1,100,2,3) has an hh-index of 22, whereas if the citation counts were (1,100,3,3)(1,100,3,3) then the hh-index would be 33.

To up her hh-index, Bessie is planning to write a survey article citing several of her past papers. Due to page limits, she can include at most LL citations in this survey (0≤L≤1050 \leq L \leq 10^5), and of course she can cite each of her papers at most once.

Help Bessie determine the maximum hh-index she may achieve after writing this survey.

Note that Bessie's research advisor should probably inform her at some point that writing a survey solely to increase one's hh-index is ethically dubious; other academics are not recommended to follow Bessie's example here.

Input

The first line of input contains NN and LL.

The second line contains NN space-separated integers c_1,…,c_Nc\_1,\ldots, c\_N.

Output

The maximum hh-index Bessie may achieve after writing the survey.

Examples2

  1. Example 1

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

    Input
    4 1
    1 100 2 3
    
    Expected output
    3