Codeforces Round #414, rated, Div. 1 + Div. 2 A. Bank Robbery
来源:互联网 发布:淘宝苹果旗舰店 编辑:程序博客网 时间:2024/06/05 11:11
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 the xi-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 784 7 5 5 3 6 2 8
4
6 5 751 5 7 92 3
0
#include <stdio.h>#include <bits/stdc++.h>#define mod 1000000007#define read(); freopen("C:\\Users\\Administrator\\Desktop\\input.txt","r",stdin);typedef long long ll;using namespace std;int a,b,c,n;int vis[100005];int main(){cin>>a>>b>>c>>n;for(int i=1;i<=n;i++){cin>>vis[i];}sort(vis+1,vis+1+n);a=lower_bound(vis+1,vis+1+n,a)-vis;int l=a-1,r=a;int ans=0;while(l>=1 && vis[l--]>b) ans++;while(r<=n && vis[r++]<c) ans++;cout<<ans<<endl;return 0;}
- Codeforces Round #414, rated, Div. 1 + Div. 2 A. Bank Robbery
- (Codeforces Round #413, rated, Div. 1 + Div. 2)(A+B)
- Codeforces Round#333 div.1 E A Museum Robbery
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A. Carrot Cakes
- codeforcesPlayrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)A题
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A题
- Educational Codeforces Round 33 (Rated for Div. 2) A
- Codeforces Round #414, rated, Div. 1 + Div. 2 B. Cutting Carrot+【等腰三角形等比例缩小】
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A -- D
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A. Vicious Keyboard
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)B
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains(树状数组)
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains 乱搞
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) B. T-shirt buying
- CodeforcesPlayrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)C题C. Fountains
- [Updating] Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) 解题报告
- war包和jar包
- DOM/BOM
- Arduino 舵机驱动板编程
- Excel VBA 中 Excel文件的操作
- 《利用Python进行数据分析》.(Wes McKinney).[PDF].pdf
- Codeforces Round #414, rated, Div. 1 + Div. 2 A. Bank Robbery
- POJ 2139 Six Degrees of Cowvin Bacon 最短路
- c语言题目集合
- HDU2222-AC自动机
- I。quadratic equation 山东第八届省赛
- LeetCode 26. Remove Duplicates from Sorted Array
- 国内用户使用Android Studio 提示帮助文档 一直显示:fetching documentation解决方案
- 开源|效果惊人!Cycle Gan瞬间让马变成斑马
- 机器学习:几种常见的学习方法