Tagy: Python 2 dequeue
Obtiažnosť: hard

Flowers

Baska is a bee. She lives in a hive close to a large garden. The garden contains $n$ flowers which are grown sequentially in a line. Each flower has its own taste, which influences the honey flavor made of this flower. Baska wants to collect some pollen from a segment which contains exactly $k$ flowers. The pollen from these flowers will be then used to produce a jar of a honey. Baska cares about the resulting honey flavor she makes. The flavor of a honey is a minimum from all the tastes of flowers which are contained in the honey. Now, she’s interested in honey flavor which she can made from various segments of flowers. But she’s good in collecting pollen, not in math. So try and help her. Maybe, she will give you some honey in return.

Úloha

You are given the description of the flower line - $n$ positive integers $a_1, \dots a_n$, where $a_i$ represents the taste of the $i$-th flower. Furthermore, you are given $q$ questions that Baska asks. Each questions is a positive integer $i \leq n − k + 1$ and represents the position of the first flower in the sequence. Compute the honey flavor made out of this flower sequence, i.e., the honey flavor of flowers in positions $i, i+1, \dots, i + k − 1$ which have tastes $a_i, a_{i+1}, \dots , a_{i+k−1}$.

Vstup

The first line of the input contains three integers $n, k, q$ - the number of flowers in the garden, the number of flowers in the segment which Baska wants to visit and the number of Baska’s questions.

The following line contains $n$ positive integers $a_1, a_2, \dots, a_n$ representing the tastes of flowers in the order how they are grown.

Each of the following $q$ lines contains a single integer number $p_i$ - the position of the first flower which Baska plans to visit.

Výstup

For each question pi output a single line containing a single integer the flavor of honey that Baska gets if she starts collecting the pollen from the $p_i$-th flower.

Príklad

Vstup

Výstup

5 2 3
4 2 5 7 1
2
3
4
2
5
1
Ak chceš riešiť túto úlohu, musíš sa najprv prihlásiť.