CF794A.Bank Robbery
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 x__i. 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.
一名劫匪试图抢劫一家银行,但未能完成任务。然而,他成功打开了所有保险箱。
银行客户奥列格酷爱金钱(谁不是呢?),于是决定利用这次失败的抢劫,从保险箱中窃取一些钱。许多保险箱排成一行,从左起第 i 个保险箱称为保险箱 i。所有保险箱中总共剩下 n 张钞票。第 i 张钞票位于保险箱 xi 中。此时奥列格位于保险箱 a。有两名保安:其中一名守卫保险箱 b,且满足 b<a,即第一位保安在奥列格左侧;另一名守卫保险箱 c,且满足 c>a,即第二位保安在奥列格右侧。
这两名保安非常懒惰,因此他们不会移动。每一秒,奥列格可以执行以下两种操作之一:
- 取走当前保险箱中的全部钞票;
- 移动到任意一个相邻的保险箱。
但他在任何时候都不能访问由保安守卫的保险箱,否则可能因盗窃而被起诉。
请计算奥列格最多能获取多少张钞票。
输入格式
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 _x_1, _x_2, ..., x__n (1 ≤ x__i ≤ 109), denoting that the i-th banknote is located in the x__i-th safe. Note that x__i are not guaranteed to be distinct.
输入的第一行包含三个用空格分隔的整数 a、b 和 c(满足 1 ≤ b < a < c ≤ 109),分别表示奥列格、第一位保安和第二位保安的位置。
输入的第二行包含一个整数 n(1 ≤ n ≤ 105),表示钞票的数量。
输入的第三行包含 n 个用空格分隔的整数 x1,x2,...,xn(1 ≤ xi ≤ 109),表示第 i 张钞票位于第 xi 个保险箱中。注意:xi 不保证互不相同。
输出格式
Output a single integer: the maximum number of banknotes Oleg can take.
输出一个整数:Oleg 能取走的纸币的最大数量。
输入输出样例
输入#1
5 3 7 8 4 7 5 5 3 6 2 8
输出#1
4
输入#2
6 5 7 5 1 5 7 92 3
输出#2
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 3 and 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.
在第一个样例中,奥列格可以取走位置 4、5、6 处的钞票(注意:位置 5 处有 2 张钞票)。由于奥列格无法经过第二名保安,因此他不能取走保险箱 7 和 8 中的钞票。同理,由于奥列格无法经过第一名保安,因此他也不能取走位置 3 和 2 处的钞票。因此,他最多可取走 4 张钞票。
对于第二个样例,奥列格无法在不碰到任何一名保安的情况下取走任意一张钞票。
输入解题思路,AI测评打分。不知道怎么写?