CF794A.Bank Robbery

普及/提高-

通过率:0%

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 ii -th safe from the left is called safe ii . There are nn banknotes left in all the safes in total. The ii -th banknote is in safe xix_{i} . Oleg is now at safe aa . There are two security guards, one of which guards the safe bb such that b<a , i.e. the first guard is to the left of Oleg. The other guard guards the safe cc 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, aa , bb and cc ( 1<=b<a<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 nn ( 1<=n<=1051<=n<=10^{5} ), denoting the number of banknotes.

The next line of input contains nn space-separated integers x1,x2,...,xnx_{1},x_{2},...,x_{n} ( 1<=xi<=1091<=x_{i}<=10^{9} ), denoting that the ii -th banknote is located in the xix_{i} -th safe. Note that xix_{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 44 , 55 , 66 (note that there are 22 banknotes at position 55 ). Oleg can't take the banknotes in safes 77 and 88 because he can't run into the second security guard. Similarly, Oleg cannot take the banknotes at positions 33 and 22 because he can't run into the first security guard. Thus, he can take a maximum of 44 banknotes.

For the second sample, Oleg can't take any banknotes without bumping into any of the security guards.

首页