Codeforces Round #408 (Div. 2) A. Buying A House
来源:互联网 发布:mac转换windows快捷键 编辑:程序博客网 时间:2024/06/03 18:26
题目链接:Buying A House
题意很简单,给你n,m,k,代表总共的房子数,妹子住的房子位置,k元钱,然后是n个数,0代表这个房子有人住,否则代表这个房子的价格,问你能在k元里买到的离妹子最近的房子距离妹子所在地有多远,两房子之间距离为定值10m。从前往后扫一遍就可以了,我的做法是从妹子所在的房子往后扫找最小距离,再往前扫找最小距离,两个再取最小就可以了
#include <iostream>#include <algorithm>#include <stdio.h>#include <set>#include <vector>#include <map>using namespace std;typedef long long ll;int main(){ ios::sync_with_stdio(false); ll n,m,k,sum,a[1005]; while(cin>>n>>m>>k){ int dis1 = 0x3f3f3f3f,dis2 = 0x3f3f3f3f; for(int i = 1;i <= n;i++) cin>>a[i]; for(int i = m;i <= n;i++) if(a[i] <= k&&a[i] != 0) {dis1 = (i-m)*10;break;} for(int i = m;i >= 1;i--) if(a[i] <= k&&a[i] != 0) {dis2 = (m-i)*10;break;} cout<<min(dis1,dis2)<<endl; } return 0;}
0 0
- Codeforces Round #408 (Div. 2) A Buying A House
- codeforces round#408(div.2) A. Buying A House
- Codeforces Round #408 (Div. 2) A. Buying A House
- Codeforces Round #408 A. Buying A House
- Codeforces Round #408 (Div. 2) A.Buying A House【模拟】水题~
- Codeforces Round #346 (Div. 2) -A. Round House(模拟)
- Codeforces Round #346 (Div. 2)--A. Round House
- Codeforces Round #346 (Div. 2) A.Round House
- Codeforces Round #346 (Div. 2) A. Round House
- Codeforces Round #346 (Div. 2) - A Round House
- Codeforces Round #346 (Div. 2) A. Round House
- Codeforces Round #346 (Div. 2) A. Round House
- CodeForces 796A Buying A House
- 【Codeforces 796 A. Buying A House】
- Buying A House (Codeforces-796A)
- A. Buying A House
- A. Buying A House
- 【CodeForces】[659A]Round House
- 关于warning: mysql_result() expects parameter 1 to be resource,object given in……的解决方法
- Ubuntu 16.04 安装matlab 证书无法写入的问题
- java 中的集合(十三) LinkedHashMap源码分析
- HttpWatch v10.x发布,支持在Firefox 35-35版中使用HTTP/2
- matlab2012b与VS2012混编总结(2)——将.m文件编译成dll和lib库文件过程中遇到的问题及解决办法
- Codeforces Round #408 (Div. 2) A. Buying A House
- 降维方法学习
- 递归漫谈(二)
- FlashBuilder+FariyGUI+Laya引擎开发H5游戏
- Android layout属性大全
- RecyclerView 简单使用
- 函数的调用
- 关于WindowListener的使用
- iOS多线程并发,串行,同步,异步