| UNICAMP Selection Contest 2025 |
|---|
| Finished |
Matryoshka dolls. Illustrative. In the problem, the dolls may be out of order and are in a single line. During his visit to Moscow, Russia, in 2021, during the ICPC World Finals, Arthur entered a charming antique shop and came across a display case filled with Matryoshka dolls, famous Russian dolls that can be nested inside one another. The dolls were arranged in a line but did not follow any size order. Some were larger, others smaller, and some were exactly the same size.
Arthur decided to buy some dolls, choosing a continuous set of dolls to take home. However, since Arthur will have to check in his luggage, he began to worry about the strength of the group of dolls during transport. Arthur defined that the strength of a group of dolls is calculated as follows. Let $$$T_i$$$ be the size of the $$$i$$$-th doll, the strength of the set of dolls starting from doll $$$l$$$ to doll $$$r$$$ is given by:
$$$$$$ F = (r-l+1)^2 \cdot \min\limits_{k=l}^{r}\left\{T_{k}\right\} $$$$$$
That is, the number of dolls squared times the size of the smallest doll.
It is no wonder that Arthur is in the world finals, so calculating which group would be the strongest or weakest is too easy for him. Instead, Arthur wants to choose the group with the $$$K$$$-th smallest strength.
Formally, the sizes of each doll are given as an array of $$$N$$$ integers $$$T_i$$$. Among all $$$\frac{N(N+1)}{2}$$$ ways to choose a continuous sequence of dolls (i.e., subarrays), which one has the $$$K$$$-th smallest strength?
The first line contains two integers $$$N$$$ and $$$K$$$ ($$$1 \leq N \leq 10^{5}$$$, $$$1 \leq K \leq \frac{N(N+1)}{2}$$$) — the number of dolls in the display case and the desired value $$$K$$$.
The second line contains $$$N$$$ integers $$$T_1, T_2, \dots, T_N$$$ $$$(1 \leq T_i \leq 10^7)$$$ — the sizes of the dolls from left to right.
Print a single integer: the strength of the group that is in the $$$K$$$-th position among all possible groups when ordered in increasing order of strength.
Note that this number can be very large.
4 52 1 3 2
4
3 41 1 1
4
3 61 1 1
9
| Name |
|---|


