码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #408 (Div. 2) A

时间:2017-04-12 23:44:42      阅读:413      评论:0      收藏:0      [点我收藏+]

标签:for   money   pos   sed   rom   oss   round   amp   pac   

Description

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 m of a village. There are n houses in that village, lining in a straight line from left to right: house 1, house 2, ..., housen. 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 a1,?a2,?...,?an that denote the availability and the prices of the houses. If house i is occupied, and therefore cannot be bought, then ai equals 0. Otherwise, house i can be bought, and ai 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 nm, and k (2?≤?n?≤?100, 1?≤?m?≤?n1?≤?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 a1,?a2,?...,?an (0?≤?ai?≤?100) — denoting the availability and the prices of the houses.

It is guaranteed that am?=?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.

Examples
input
5 1 20
0 27 32 21 19
output
40
input
7 3 50
62 0 0 0 99 33 22
output
30
input
10 5 100
1 0 1 0 0 0 0 0 1 1
output
20
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?=?40meters.

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 30meters away, while house m?=?3 and house 7 are 40 meters away.

题意:就是说有k钱,能买小于k的房子,0是不能买的,告诉我们心爱的妹子住哪个点,问买的房子距心爱妹子最近的距离是多少

解法:模拟

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 int n,k,m;
 5 int maxn=101*100;
 6 int num;
 7 int main()
 8 {
 9     cin>>n>>m>>k;
10     for(int i=1;i<=n;i++)
11     {
12         cin>>num;
13         if(num<=k&&num)
14         {
15             maxn=min(maxn,abs(m-i));
16         }
17     }
18     cout<<maxn*10<<endl;
19     return 0;
20 }

 

Codeforces Round #408 (Div. 2) A

标签:for   money   pos   sed   rom   oss   round   amp   pac   

原文地址:http://www.cnblogs.com/yinghualuowu/p/6701505.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!