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 ≤ 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 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是不能买的,告诉我们心爱的妹子住哪个点,问买的房子距心爱妹子最近的距离是多少

解法:模拟

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k,m;
int maxn=*;
int num;
int main()
{
cin>>n>>m>>k;
for(int i=;i<=n;i++)
{
cin>>num;
if(num<=k&&num)
{
maxn=min(maxn,abs(m-i));
}
}
cout<<maxn*<<endl;
return ;
}

Codeforces Round #408 (Div. 2) A的更多相关文章

  1. Codeforces Round #408 (Div. 2)(A.水,B,模拟)

    A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  2. Codeforces Round #408 (Div. 2)C. Bank Hacking(STL)

    题目链接:http://codeforces.com/problemset/problem/796/C 题目大意:有n家银行,第一次可以攻击任意一家银行(能量低于自身),跟被攻击银行相邻或者间接相邻( ...

  3. Codeforces Round #408 (Div. 2) C. Bank Hacking

    http://codeforces.com/contest/796/problem/C Although Inzane successfully found his beloved bone, Zan ...

  4. Codeforces Round #408 (Div. 2) A B C 模拟 模拟 set

    A. Buying A House time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  5. Codeforces Round #408 (Div. 2) D - Police Stations

    地址:http://codeforces.com/contest/796/problem/D 题目: D. Police Stations time limit per test 2 seconds ...

  6. Codeforces Round #408 (Div. 2) B

    Description Zane the wizard is going to perform a magic show shuffling the cups. There are n cups, n ...

  7. Codeforces Round #408 (Div. 2)

    C. Bank Hacking 题目大意:给出一棵n个节点的树,每个节点有一个权值,删掉一个点的代价为当前这个点的权值,并且会使其相邻点和距离为2且中间隔着未被删除的点的点权值加1,现在选一个点开始删 ...

  8. Codeforces Round #408 (Div. 2) 题解【ABCDE】

    A - Buying A House 题意:给你n个房间,妹子住在第m个房间,你有k块钱,你想买一个离妹子最近的房间.其中相邻的房间之间距离为10,a[i]=0表示已经被别人买了. 题解:扫一遍更新答 ...

  9. Codeforces Round #408 (Div. 2) D. Police Stations(最小生成树+构造)

    传送门 题意 n个点有n-1条边相连,其中有k个特殊点,要求: 删去尽可能多的边使得剩余的点距特殊点的距离不超过d 输出删去的边数和index 分析 比赛的时候想不清楚,看了别人的题解 一道将1个联通 ...

  10. Codeforces Round #408 (Div. 2) C.Bank Hacking(二分)

    传送门 题意 给出n个银行,银行之间总共有n-1条边,定义i与j有边相连为neighboring,i到j,j到k有边,则定义i到k的关系为semi- neighboring, 每家银行hack的难度为 ...

随机推荐

  1. vue 开发前准备工作

    工欲善其事,必先利其器. 第一步,选择一个合适的编辑器: 看vue官网上,有推荐用HBuilder X这个编辑器,这个我在开发微信小程序的时候,就是用的这个编辑器,还可以,挺好用的,也可以用git做版 ...

  2. POJ 2482 Stars in Your Window(线段树+扫描线)

    题目链接 非常不容易的一道题,把每个点向右上构造一个矩形,将问题转化为重合矩形那个亮度最大,注意LL,注意排序. #include <cstdio> #include <cstrin ...

  3. 文件批量转换成UTf-8

    yum install -y enca 在文件夹根目录下面创建文件:iconv_shell.sh 里面填写下面的内容: #!/bin/bash for file in `find ./ -name ' ...

  4. mysql无法远程访问

    最近使用Navicat for MySQl访问远程mysql数据库,出现报错, 显示“1130 - Host'xxx.xxx.xxx.xxx' is not allowed to connect to ...

  5. Hadoop MapReduce输入输出类型

    一.输入格式 1.输入分片split 一个分片对应一个map任务: 一个分片包含一个表(整个文件)上的若干行,而一条记录(单行)对应一行: 分片包含一个以字节为单位的长度 和 一组存储位置,分片不包含 ...

  6. (C)strcpy ,strncpy和strlcpy的基本用法

    好多人已经知道利用strncpy替代strcpy来防止缓冲区越界. 但是如果还要考虑运行效率的话,也许strlcpy是一个更好的方式. 1. strcpy strcpy 是依据 /0 作为结束判断的, ...

  7. 用secureCRT ssh登陆不显示用户名和路径解决方案 分类: 软件工具学习 2015-03-18 16:52 36人阅读 评论(0) 收藏

    方法1         每次开始的时候输入 bash 虽然只能保存一次,但是简便. 方法2 用       vi ~/.bash_profile   编辑这个文件,  有时会提示这个文件不存在,直 ...

  8. 装饰器模式(IO流案例)

    装饰器模式,也成为包装模式,顾名思义,就是对已经存在的某些类进行装饰,以此来扩展一些功能.其结构图如下: Component为统一接口,也是装饰类和被装饰类的基本类型. ConcreteCompone ...

  9. BZOJ_4423_[AMPPZ2013]Bytehattan_对偶图+并查集

    BZOJ_4423_[AMPPZ2013]Bytehattan_对偶图+并查集 Description 比特哈顿镇有n*n个格点,形成了一个网格图.一开始整张图是完整的. 有k次操作,每次会删掉图中的 ...

  10. 「LuoguP4753」濑 River Jumping(贪心

    Description 有一条宽度为 N 的河上,小D位于坐标为 0 的河岸上,他想到达坐标为 N 的河岸上后再回到坐标为 0 的位置.在到达坐标为 N 的河岸之前小D只能向坐标更大的位置跳跃,在到达 ...