Codeforces Round #408 (Div. 2) A
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.
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 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.
Print one integer — the minimum distance, in meters, from the house where the girl Zane likes lives to the house Zane can buy.
5 1 20
0 27 32 21 19
40
7 3 50
62 0 0 0 99 33 22
30
10 5 100
1 0 1 0 0 0 0 0 1 1
20
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的更多相关文章
- 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 ...
- Codeforces Round #408 (Div. 2)C. Bank Hacking(STL)
题目链接:http://codeforces.com/problemset/problem/796/C 题目大意:有n家银行,第一次可以攻击任意一家银行(能量低于自身),跟被攻击银行相邻或者间接相邻( ...
- Codeforces Round #408 (Div. 2) C. Bank Hacking
http://codeforces.com/contest/796/problem/C Although Inzane successfully found his beloved bone, Zan ...
- 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 ...
- Codeforces Round #408 (Div. 2) D - Police Stations
地址:http://codeforces.com/contest/796/problem/D 题目: D. Police Stations time limit per test 2 seconds ...
- 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 ...
- Codeforces Round #408 (Div. 2)
C. Bank Hacking 题目大意:给出一棵n个节点的树,每个节点有一个权值,删掉一个点的代价为当前这个点的权值,并且会使其相邻点和距离为2且中间隔着未被删除的点的点权值加1,现在选一个点开始删 ...
- Codeforces Round #408 (Div. 2) 题解【ABCDE】
A - Buying A House 题意:给你n个房间,妹子住在第m个房间,你有k块钱,你想买一个离妹子最近的房间.其中相邻的房间之间距离为10,a[i]=0表示已经被别人买了. 题解:扫一遍更新答 ...
- Codeforces Round #408 (Div. 2) D. Police Stations(最小生成树+构造)
传送门 题意 n个点有n-1条边相连,其中有k个特殊点,要求: 删去尽可能多的边使得剩余的点距特殊点的距离不超过d 输出删去的边数和index 分析 比赛的时候想不清楚,看了别人的题解 一道将1个联通 ...
- Codeforces Round #408 (Div. 2) C.Bank Hacking(二分)
传送门 题意 给出n个银行,银行之间总共有n-1条边,定义i与j有边相连为neighboring,i到j,j到k有边,则定义i到k的关系为semi- neighboring, 每家银行hack的难度为 ...
随机推荐
- jquery.validate ajax验证
$("#form1").validate({ rules: { ctl00$ContentPlaceHolder1$txtShopName: { remote: { type: & ...
- Java 深拷贝浅拷贝 与 序列化
一.浅拷贝.深拷贝 浅拷贝会对对象中的成员变量进行拷贝:如果是基本类型,拷贝的就是基本类型的值:如果属性是内存地址(引用类型),拷贝的就是内存地址 : 深拷贝,除了基本类型外,引用类型所引用的对象也会 ...
- 静态代理、动态代理和cglib代理
转:https://www.cnblogs.com/cenyu/p/6289209.html 代理(Proxy)是一种设计模式,提供了对目标对象另外的访问方式;即通过代理对象访问目标对象.这样做的好处 ...
- Android上的水果忍者刀锋效果(JAVA实现)
显示刀锋的View package com.wbhuang.myninjia; import java.util.ArrayList; import java.util.List; import an ...
- 用Delphi7 调用.NET 2.0的WebService 所要注意的问题(Document格式和UTF8编码)
Delphi7 调用VS.NET 2005开发的基于.NET 2.0的WebService时发生了错误.查阅资料 http://www.community.borland.com/article/bo ...
- input框只允许输入正整数、正数(包含小数)的解决方法 vue.js实现
我来打自己脸了!!!!...刚刚发现在中文输入法下是无效的,有人能解决这个问题么 如果要求input只能输入数字怎么做? 设置type="number" ? 那我如果想限制长度,此 ...
- 初探linux子系统集之led子系统(三)【转】
本文转载自:http://blog.csdn.net/eastmoon502136/article/details/37822837 世界杯结束了,德国战车夺得了大力神杯,阿根廷最终还是失败了.也许3 ...
- python读取一个英文文件,并记录每个单词出现的次数,降序输出
对文中出现的句号,逗号和感叹号做了相应的处理 sorted排序函数用法: 按照value值降序排列: sorted(dict.items(),key=lambda k:k[1],reverse=Tru ...
- LA-4356&&hdu-2469 (极角排序+扫描线)
题目链接: Fire-Control System Time Limit: 12000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
- BZOJ_4383_[POI2015]Pustynia_线段树优化建图+拓扑排序
BZOJ_4383_[POI2015]Pustynia_线段树优化建图+拓扑排序 Description 给定一个长度为n的正整数序列a,每个数都在1到10^9范围内,告诉你其中s个数,并给出m条信息 ...