Tinkoff Challenge - Final Round (Codeforces Round 414, rated, Div. 1 + Div. 2)
A
Bank Robbery
Codeforces
800
原题
←B →
翻译中…

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.

翻译中…

Input

翻译中…

The first line of input contains three space-separated integers, $*a*$, $*b*$ and $*c*$ ($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 $*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

翻译中…

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

翻译中…

Note

翻译中…

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
5 3 7
8
4 7 5 5 3 6 2 8
Output #1
4
InputCopy OutputCopy
Input #2
6 5 7
5
1 5 7 92 3
Output #2
0
InputCopy OutputCopy
题目信息
题号
794A
时间限制
2 s
内存限制
256 MB
标签
暴力
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。