Codeforces Round #414 A. Bank Robbery
2 seconds
256 megabytes
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from the safes. There are many safes arranged in a line, where the i-th safe from the left is called safe i. There are n banknotes left in all the safes in total. The i-th banknote is in safe xi. Oleg is now at safe a. There are two security guards, one of which guards the safe b such that b < a, i.e. the first guard is to the left of Oleg. The other guard guards the safe c so that c > a, i.e. he is to the right of Oleg.
The two guards are very lazy, so they do not move. In every second, Oleg can either take all the banknotes from the current safe or move to any of the neighboring safes. However, he cannot visit any safe that is guarded by security guards at any time, becaues he might be charged for stealing. Determine the maximum amount of banknotes Oleg can gather.
The first line of input contains three space-separated integers, a, b and c (1 ≤ b < a < c ≤ 109), denoting the positions of Oleg, the first security guard and the second security guard, respectively.
The next line of input contains a single integer n (1 ≤ n ≤ 105), denoting the number of banknotes.
The next line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109), denoting that the i-th banknote is located in thexi-th safe. Note that xi are not guaranteed to be distinct.
Output a single integer: the maximum number of banknotes Oleg can take.
5 3 7
8
4 7 5 5 3 6 2 8
4
6 5 7
5
1 5 7 92 3
0
In the first example Oleg can take the banknotes in positions 4, 5, 6 (note that there are 2 banknotes at position 5). Oleg can't take the banknotes in safes 7 and 8 because he can't run into the second security guard. Similarly, Oleg cannot take the banknotes at positions 3and 2 because he can't run into the first security guard. Thus, he can take a maximum of 4 banknotes.
For the second sample, Oleg can't take any banknotes without bumping into any of the security guards.
题目大意:
有一个小偷想去偷银行的钱,他打听到银行一共有n个保险箱在一条直线上给出每个保险箱的位置
(每一个位置上不一定只有一个保险箱)
小偷现在在a,有两个保安他们分别在b和c处(a > b a < c) 两个保安特别懒他们保持不动
小偷不能越过保安去偷钱,问小偷可以偷多少个保险箱
解题思路:
可能是时间长不敲代码了吧。被这么水的题困了半天。
输入一个位置只要判断当前位置是否在两个保安的位置之间,是+1 然后输出即可(真是被自己蠢到了)
AC代码:
#include<stdio.h>
int main ()
{
int a,b,c,i,n,p,sum;
while (~scanf("%d%d%d",&a,&b,&c))
{
scanf("%d",&n); sum = ;
for (i = ; i < n; i ++)
{
scanf("%d",&p);
if (p > b && p < c)
sum ++;
}
printf("%d\n",sum);
}
return ;
}
Codeforces Round #414 A. Bank Robbery的更多相关文章
- Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) 【ABC】
老年人题解,语言python3 A - Bank Robbery 题意:给你ABC,以及n个数,问你在(B,C)之间的数有多少个. 题解:对于每个数判断一下就好了嘛 x,y,z = map(int,i ...
- Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) 继续跪一把
这次的前三题挺简单的,可是我做的不快也不对. A. Bank Robbery time limit per test 2 seconds memory limit per test 256 megab ...
- Codeforces Round #414 C. Naming Company
http://codeforces.com/contest/794/problem/C 题意: 有两个人要为公司起名字,每个人手中都有n个字符,现在要取一个n个字符长度的公司名.两人轮流取名,每次选择 ...
- Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2)
A: 思路:就是找b,c之前有多个s[i] 代码: #include<stdio.h>#define ll long longusing namespace std;ll a,b,c;in ...
- 【构造】Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) D. Labelling Cities
考试的时候想的是,将所有的完全子图缩起来,然后如果剩下的是一条链,依次对其进行标号即可. 看了官方题解,发现完全子图这个条件太强了,缩点的条件仅仅需要保证原本两个点的“邻接表”相同即可.(注意这里的“ ...
- 【贪心】【multiset】Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) C. Naming Company
考虑两个人,先把各自的集合排个序,丢掉一半,因为比较劣的那一半一定用不到. 然后贪心地放,只有两种决策,要么把一个最优的放在开头,要么把一个最劣的放在结尾. 如果我的最优的比对方所有的都劣(或等于), ...
- Codeforces Round #414
A =w= B qvq C(贪心) 题意: Alice和Bob分别有长度为n(n<=1e5)的字符串,Alice先手,每次从自己的字符串中抽出一个字母放到新字符串的某个位置,一共轮流n次,也就是 ...
- codeforces round #414 div1+div2
A:判断一下就可以了 #include<bits/stdc++.h> using namespace std; typedef long long ll; int a, b, c, n; ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
随机推荐
- C++ 创建类时常考虑的问题
目录 继承 抽象接口 标准设计模式 初始化与析构模型 定义复制构造函数和赋值操作 模板 操作符 类型转换操作符 友元 非功能性约束 本文仅以c++为例,简要说明创建一个类时我们需要考虑的问题.创建一个 ...
- 项目Alpha冲刺 6
作业描述 课程: 软件工程1916|W(福州大学) 作业要求: 项目Alpha冲刺(团队) 团队名称: 火鸡堂 作业目标: 介绍第6天冲刺的项目进展.问题困难和心得体会 1.团队信息 队名:火鸡堂 队 ...
- linux ssh 上传 文件
在linux下一般用scp这个命令来通过ssh传输文件. 1.从服务器上下载文件scp username@servername:/path/filename /var/www/local_dir(本地 ...
- J15W-J45W铜截止阀厂家,J15W-J45W铜截止阀价格 - 专题栏目 - 无极资讯网
无极资讯网 首页 最新资讯 最新图集 最新标签 搜索 J15W-J45W铜截止阀 无极资讯网精心为您挑选了(J15W-J45W铜截止阀)信息,其中包含了(J15W-J45W铜截止阀)厂家,(J15 ...
- 3dsmax2013卸载/安装失败/如何彻底卸载清除干净3dsmax2013注册表和文件的方法
3dsmax2013提示安装未完成,某些产品无法安装该怎样解决呢?一些朋友在win7或者win10系统下安装3dsmax2013失败提示3dsmax2013安装未完成,某些产品无法安装,也有时候想重新 ...
- Django跨域解决方法
from django.utils.deprecation import MiddlewareMixin class Mymiddle(MiddlewareMixin): def process_re ...
- jQuery练习 | 模态对话框(添加删除)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- SQL Cookbook—查询、排序
涉及到的问题1.在select语句中使用条件逻辑2.限制返回的行数3.从表中随机返回n条记录4.将空值转换为实际值5.对字母和数字混合的数据排序6.处理排序空值7.根据数据项的键排序–8.从一个表中查 ...
- Call to a member function assign() on null
Thinkphp: 在子控制器里面写了一个构造函数,如下 //构造函数 public function __construct(){ echo 1; } 结果页面报错了 ----> Call ...
- 游戏开发者注意!这个音频SDK可以完美兼容所有主流游戏引擎
欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由腾讯游戏云 发表于云+社区专栏 在网络游戏中,无论是大逃杀.棋牌类.电子竞技类还是娱乐休闲类小游戏,玩家和玩家之间的互动.语音聊天是一 ...