A. Buying A House

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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, ..., 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 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 ≤ 1001 ≤ 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 = 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.


解题说明:本题是一道模拟题,按照要求找到能买得起最近的房子即可。


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<iostream>
using namespace std;

#define MAX 1000000009

int main()
{
	int i,n,m,k,min=MAX,t,temp;
	scanf("%d %d %d",&n,&m,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&t);
		if(t>0 && t<=k)
		{
			temp=abs(m-i);
			if(temp<min)
			{
				min=temp;
			}
		}
	}
	printf("%d\n",(min*10));
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我看看这段话有没有语法错误:The first effect of guaranteeing people have basic financial products and services is increasing the overall quality of people’s lives. Ensuring reliable access to financial products and services can contribute to helping families and companies plan the future from two aspects, long-term goals and unexpected emergencies (The World Bank, 2022). Long-term goals mean long-term investments such as investments in health: saving money against illness, saving for a child’s education, saving for a house or car, etc. Unexpected emergencies mean managing risk, that is, people can apply for a loan from the bank when they are in the face of a sudden bankruptcy or business shock. Furthermore, when people meet weather financial shocks, the government and banks will give some financial assistance. With these financial services, people have a basic guarantee of life and a clear plan for the future in the meanwhile. Guarantee of financial services leads them to save a sum of money in a safe bank account for buying a house, providing funds for children’s education, and buying medical insurance for both themselves and their families to prevent the sudden arrival of diseases. In daily life, online payment improves life efficiency such as reducing queuing time. Additionally, in occupational life, financial guarantees can encourage and empower young people can be bolder to pursue their entrepreneurial dreams by providing them with start-up funds from banks. All in all, the guarantee of financial products leads to individuals plan for their financial futures and improve their overall quality of life.
05-05

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值