CF796A.Buying A House

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

The girl lives in house mm of a village. There are nn houses in that village, lining in a straight line from left to right: house 11 , house 22 , ..., house nn . The village is also well-structured: house ii and house i+1i+1 ( 1<=i<n ) are exactly 1010 meters away. In this village, some houses are occupied, and some are not. Indeed, unoccupied houses can be purchased.

You will be given nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} that denote the availability and the prices of the houses. If house ii is occupied, and therefore cannot be bought, then aia_{i} equals 00 . Otherwise, house ii can be bought, and aia_{i} represents the money required to buy it, in dollars.

As Zane has only kk 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.

输入格式

The first line contains three integers nn , mm , and kk ( 2<=n<=1002<=n<=100 , 1<=m<=n1<=m<=n , 1<=k<=1001<=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 nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 0<=ai<=1000<=a_{i}<=100 ) — denoting the availability and the prices of the houses.

It is guaranteed that am=0a_{m}=0 and that it is possible to purchase some house with no more than kk dollars.

输出格式

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

输入输出样例

  • 输入#1

    5 1 20
    0 27 32 21 19
    

    输出#1

    40
  • 输入#2

    7 3 50
    62 0 0 0 99 33 22
    

    输出#2

    30
  • 输入#3

    10 5 100
    1 0 1 0 0 0 0 0 1 1
    

    输出#3

    20

说明/提示

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

In the second sample, Zane can buy houses 66 and 77 . It is better to buy house 66 than house 77 , since house m=3m=3 and house 66 are only 3030 meters away, while house m=3m=3 and house 77 are 4040 meters away.

首页