Problem G
Hockey Fans
Some of the best hockey is when the Notnomde and Yraglac professional hockey teams play. But it isn’t always a polite game: the home team boos the other team’s goalie regularly throughout the game.
You don’t like to boo the other team’s goalie, it is unsportsmanlike. But you are with friends who do and you feel some peer pressure. So you will boo the goalie exactly $M$ times during the game to appease them. Ideally, you would boo when the crowd is noisiest so your rude display is unlikely to be heard.
The boo chant takes exactly $S$ seconds to complete. You have also watched enough hockey to have a pretty good prediction about the decibel level in the arena each second during the game.
To mask your boo chant as much as possible, you will find the largest value $D$ such you that it is possible to shout out the boo chant $M$ times during the game such that no two shoutouts overlap, each shout out is uninterupted (i.e. occurs in $S$ consecutive seconds), and all of the $S \cdot M$ seconds you spend booing their goalie are done when the predicted decibel level is at least $D$. You have excellent lung capacity and are able to start a chant immediately after you finish one.
Input
The first line of input contains three integers $N$, $S$, and $M$ ($1 \leq N,S,M \leq 200\, 000$, $S \cdot M \leq N$). Here, $N$ is the number of seconds the game is expected to last. The next line contains $N$ integers $d_1, d_2, \ldots , d_n$ ($0 \leq d_i \leq 10^9$). Here $d_i$ indicates the decibel level you expect at during second $i$ of the game.
Output
Output a single integer $D$ that is the maximum value such that, at least according to your predictions for the decibel levels throughout the game, you can shout $M$ boo chants throughout the game where all shouts take place at times where the decibel level is at least $D$.
Sample Input 1 | Sample Output 1 |
---|---|
7 2 3 1 1 1 0 1 1 1 |
0 |
Sample Input 2 | Sample Output 2 |
---|---|
7 2 3 1 1 0 1 1 1 1 |
1 |
Sample Input 3 | Sample Output 3 |
---|---|
20 3 3 6 6 0 4 8 7 6 4 7 5 9 3 8 2 4 2 1 9 4 8 |
4 |