Good Bye 2015
E
New Year and Three Musketeers
Codeforces
2400
原题
← DF →
翻译中…

Do you know the story about the three musketeers? Anyway, you must help them now.

翻译中…

Richelimakieu is a cardinal in the city of Bearis. He found three brave warriors and called them the three musketeers. Athos has strength $*a*$, Borthos strength $*b*$, and Caramis has strength $*c*$.

翻译中…

The year 2015 is almost over and there are still $*n*$ criminals to be defeated. The $*i*$-th criminal has strength $*t*_{*i*}$. It's hard to defeat strong criminals — maybe musketeers will have to fight together to achieve it.

翻译中…

Richelimakieu will coordinate musketeers' actions. In each hour each musketeer can either do nothing or be assigned to one criminal. Two or three musketeers can be assigned to the same criminal and then their strengths are summed up. A criminal can be defeated in exactly one hour (also if two or three musketeers fight him). Richelimakieu can't allow the situation where a criminal has strength bigger than the sum of strengths of musketeers fighting him — a criminal would win then!

翻译中…

In other words, there are three ways to defeat a criminal.

翻译中…
  • A musketeer of the strength $*x*$ in one hour can defeat a criminal of the strength not greater than $*x*$. So, for example Athos in one hour can defeat criminal $*i*$ only if $*t*_{*i*} ≤ *a*$.
  • Two musketeers can fight together and in one hour defeat a criminal of the strength not greater than the sum of strengths of these two musketeers. So, for example Athos and Caramis in one hour can defeat criminal $*i*$ only if $*t*_{*i*} ≤ *a* + *c*$. Note that the third remaining musketeer can either do nothing or fight some other criminal.
  • Similarly, all three musketeers can fight together and in one hour defeat a criminal of the strength not greater than the sum of musketeers' strengths, i.e. $*t*_{*i*} ≤ *a* + *b* + *c*$.
翻译中…

Richelimakieu doesn't want musketeers to fight during the New Year's Eve. Thus, he must coordinate their actions in order to minimize the number of hours till all criminals will be defeated.

翻译中…

Find the minimum number of hours to defeat all criminals. If musketeers can't defeat them all then print "-1" (without the quotes) instead.

翻译中…

Input

翻译中…

The first line of the input contains a single integer $*n*$ ($1 ≤ *n* ≤ 200 000$) — the number of criminals.

翻译中…

The second line contains three integers $*a*$, $*b*$ and $*c*$ ($1 ≤ *a*, *b*, *c* ≤ 10^{8}$) — strengths of musketeers.

翻译中…

The third line contains $*n*$ integers $*t*_{1}, *t*_{2}, ..., *t*_{*n*}$ ($1 ≤ *t*_{*i*} ≤ 10^{8}$) — strengths of criminals.

翻译中…

Output

翻译中…

Print one line with the answer.

翻译中…

If it's impossible to defeat all criminals, print "-1" (without the quotes). Otherwise, print the minimum number of hours the three musketeers will spend on defeating all criminals.

翻译中…

Note

翻译中…

In the first sample Athos has strength $10$, Borthos $20$, and Caramis $30$. They can defeat all criminals in two hours:

翻译中…
  • Borthos and Caramis should together fight a criminal with strength $50$. In the same hour Athos can fight one of four criminals with strength $1$.
  • There are three criminals left, each with strength $1$. Each musketeer can fight one criminal in the second hour.
翻译中…

In the second sample all three musketeers must together fight a criminal with strength $51$. It takes one hour. In the second hour they can fight separately, each with one criminal. In the third hour one criminal is left and any of musketeers can fight him.

翻译中…

样例

Input #1
5
10 20 30
1 1 1 1 50
Output #1
2
InputCopy OutputCopy
Input #2
5
10 20 30
1 1 1 1 51
Output #2
3
InputCopy OutputCopy
Input #3
7
30 20 10
34 19 50 33 88 15 20
Output #3
-1
InputCopy OutputCopy
Input #4
6
10 5 10
10 9 5 25 20 5
Output #4
3
InputCopy OutputCopy
题目信息
题号
611E
所属比赛
时间限制
2 s
内存限制
256 MB
标签
数据结构
贪心
排序

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