304135: CF794A. Bank Robbery

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Bank Robbery

题意翻译

- 有一家有若干个保险柜的银行,从左往右分别标号为 $1,2,3,...$。 - 有 $n$ 张钞票,其中第 $i$ 号钞票在第 $x_i$ 号保险柜里。 - 一个小偷在 $a$ 号保险柜,他想偷走保险柜里面尽可能多的钞票。 - 有两个警察,一个警察在 $b(b<a)$ 号保险柜处,一个警察在 $c(c>a)$ 处,他们都不会动。 - 小偷可以偷走箱子里面的钞票,也可以移动到相邻的保险柜,但是他不能走到**任何一个**有警察看守的保险柜。 - 求这个小偷最多可以偷走多少张钞票。 - $1\leqslant b<a<c\leqslant 10^9,1\leqslant n\leqslant 10^5,1\leqslant x_i\leqslant 10^9$。

题目描述

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&lt;a $ , i.e. the first guard is to the left of Oleg. The other guard guards the safe $ c $ so that $ c&gt;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&lt;a&lt;c<=10^{9} $ ), 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<=10^{5} $ ), denoting the number of banknotes. The next line of input contains $ n $ space-separated integers $ x_{1},x_{2},...,x_{n} $ ( $ 1<=x_{i}<=10^{9} $ ), denoting that the $ i $ -th banknote is located in the $ x_{i} $ -th safe. Note that $ x_{i} $ are not guaranteed to be distinct.

输出格式


Output a single integer: the maximum number of banknotes Oleg can take.

输入输出样例

输入样例 #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.

Input

题意翻译

- 有一家有若干个保险柜的银行,从左往右分别标号为 $1,2,3,...$。 - 有 $n$ 张钞票,其中第 $i$ 号钞票在第 $x_i$ 号保险柜里。 - 一个小偷在 $a$ 号保险柜,他想偷走保险柜里面尽可能多的钞票。 - 有两个警察,一个警察在 $b(b<a)$ 号保险柜处,一个警察在 $c(c>a)$ 处,他们都不会动。 - 小偷可以偷走箱子里面的钞票,也可以移动到相邻的保险柜,但是他不能走到**任何一个**有警察看守的保险柜。 - 求这个小偷最多可以偷走多少张钞票。 - $1\leqslant b<a<c\leqslant 10^9,1\leqslant n\leqslant 10^5,1\leqslant x_i\leqslant 10^9$。

加入题单

上一题 下一题 算法标签: