One of the scholar athletes of the Computer Olympiad was injured after hitting a jump…
- User
One of the scholar athletes of the Computer Olympiad was injured after hitting a jump serve in the volleyball game and the doctor came to the club to treat him. After treating him, Mrs. Doctor notices a long line of Computer Olympiad scholars in front of the site, a very long line formed to announce the result of the second practical test. For unknown reasons (probably strong test cases), the children have been waiting for a long time and no results have been announced. For this reason, children try to estimate a certain rank for themselves.
Their method is as follows k The first k people in the queue make an initial estimate of their rank based on their performance in the test, and the rest of the people in the queue consider an estimated rank for themselves according to the rank of the people in front of them. They are in order (individual first k + 1 k+1-th, then k + 2 k+2-th and ...) estimate their rank in this way that the rank of k k people ask in front of them (i.e. Fred i i-th queue of people i
k i−k-th to i
1 asks the i−1th queue for their estimated rank) and, given that they are too optimistic, the smallest rank that none of k They consider the k people in front of them as their rank.
The image below shows the estimate of the first six people if k
4 k=4 shows.
Description of the image
input In the first line of input, two natural numbers in order k k and n n has come.
The second line of the sequence a 1 , a 2 , . . . , a k a 1 , a 2 ,...,a k shows that in it a i a i Initial estimate of the individual i is the i-th queue.
May be in between k The first two people have the same estimated rank.
1 ≤ k ≤ 1
000
000 1≤k≤1 000 000 k < n ≤ 1 0 12 k<n≤10 12
0 ≤ a 1 , a 2 , . . . , a k ≤ 1 0 9 0≤a 1 , a 2 ,...,a k ≤10 9
output In the only line of estimated output that individual n Print the nth row of its rank.
Sub-issues Constraint score subproblem 1 10 k ≤ 500 k≤500, n ≤ 5
000 n≤5 000 220 k ≤ 500 k≤500 3 40 k , n ≤ 100
000 k, n ≤ 100 000 4 20 k ≤ 100
000 k≤100 000 5 10 without additional restrictions Example Sample entry 1 4 5 4 7 2 2 Plain text Sample output 1 1 Plain text Sample input 2 4 6 4 7 2 2 Plain text Sample output 2 3 Plain text Sample entry 3 7 12 1 2 3 4 3 2 1 Plain text Sample output 3 4 c++
- Assistant