0526 CF#794A&G2n E- Bank Robbery



摘要:
给定范围内出现数的个数
原题目链接:CodeForces - 794A

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 aren 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 bsuch 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.

Input

The first line of input contains three space-separated integers, ab 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 the xi-th safe. Note thatxi are not guaranteed to be distinct.

Output

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

Example
Input
5 3 7
8
4 7 5 5 3 6 2 8
Output
4
Input
6 5 7
5
1 5 7 92 3
Output
0
Note

In the first example Oleg can take the banknotes in positions 456 (note that there are 2 banknotes at position 5). Oleg can't take the banknotes in safes 7and 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.

题目认识:
直接数。
注意:
题目变一下行 可以求时间,自己开始没认真读题真去求了时间。
日期:
2017 05 26
代码:
   
   
  1. #include <cstdio>
  2. #include <algorithm>
  3. #include <cmath>
  4. #include <memory.h>
  5. #include <iostream>
  6. using namespace std;
  7. #define MAX 1e9+7
  8. int a,b,c;
  9. int cnt=0;
  10. int main(){
  11. scanf("%d%d%d",&b,&a,&c);
  12. int n;scanf("%d",&n);
  13. int t;
  14. while(n--){
  15. scanf("%d",&t);
  16. if(t>a && t<c) {cnt++;//cout<<t;
  17. }
  18. }
  19. printf("%d",cnt);
  20. return 0;
  21. }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值