Codeforces Round 408 (Div. 2)
A
Buying A House
Codeforces
800
原题
←B →
翻译中…

Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us.

翻译中…

image

翻译中…

The girl lives in house $*m*$ of a village. There are $*n*$ houses in that village, lining in a straight line from left to right: house $1$, house $2$, ..., house $*n*$. The village is also well-structured: house $*i*$ and house $*i* + 1$ ($1 ≤ *i* < *n*$) are exactly $10$ meters away. In this village, some houses are occupied, and some are not. Indeed, unoccupied houses can be purchased.

翻译中…

You will be given $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ that denote the availability and the prices of the houses. If house $*i*$ is occupied, and therefore cannot be bought, then $*a*_{*i*}$ equals $0$. Otherwise, house $*i*$ can be bought, and $*a*_{*i*}$ represents the money required to buy it, in dollars.

翻译中…

As Zane has only $*k*$ dollars to spare, it becomes a challenge for him to choose the house to purchase, so that he could live as near as possible to his crush. Help Zane determine the minimum distance from his crush's house to some house he can afford, to help him succeed in his love.

翻译中…

Input

翻译中…

The first line contains three integers $*n*$, $*m*$, and $*k*$ ($2 ≤ *n* ≤ 100$, $1 ≤ *m* ≤ *n*$, $1 ≤ *k* ≤ 100$) — the number of houses in the village, the house where the girl lives, and the amount of money Zane has (in dollars), respectively.

翻译中…

The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($0 ≤ *a*_{*i*} ≤ 100$) — denoting the availability and the prices of the houses.

翻译中…

It is guaranteed that $*a*_{*m*} = 0$ and that it is possible to purchase some house with no more than $*k*$ dollars.

翻译中…

Output

翻译中…

Print one integer — the minimum distance, in meters, from the house where the girl Zane likes lives to the house Zane can buy.

翻译中…

Note

翻译中…

In the first sample, with $*k* = 20$ dollars, Zane can buy only house $5$. The distance from house $*m* = 1$ to house $5$ is $10 + 10 + 10 + 10 = 40$ meters.

翻译中…

In the second sample, Zane can buy houses $6$ and $7$. It is better to buy house $6$ than house $7$, since house $*m* = 3$ and house $6$ are only $30$ meters away, while house $*m* = 3$ and house $7$ are $40$ meters away.

翻译中…

样例

Input #1
5 1 20
0 27 32 21 19
Output #1
40
InputCopy OutputCopy
Input #2
7 3 50
62 0 0 0 99 33 22
Output #2
30
InputCopy OutputCopy
Input #3
10 5 100
1 0 1 0 0 0 0 0 1 1
Output #3
20
InputCopy OutputCopy
题目信息
题号
796A
时间限制
2 s
内存限制
256 MB
标签
暴力
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。