Codeforces Round 1004 (Div. 1)
E
Tropical Season
Codeforces
3300
原题
← D2F →
翻译中…

You have $n$ barrels of infinite capacity. The $i$-th barrel initially contains $a_i$ kilograms of water. In this problem, we assume that all barrels weigh the same.

翻译中…

You know that exactly one of the barrels has a small amount of tropical poison distributed on its surface, with a total weight of $0.179$ kilograms. However, you do not know which barrel contains the poison. Your task is to identify this poisonous barrel.

翻译中…

All the barrels are on scales. Unfortunately, the scales do not show the exact weight of each barrel. Instead, for each pair of barrels, they show the result of a comparison between the weights of those barrels. Thus, for any two barrels, you can determine whether their weights are equal, and if not, which barrel is heavier. The poison and water are included in the weight of the barrel.

翻译中…

The scales are always turned on, and the information from them can be used an unlimited number of times.

翻译中…

You also have the ability to pour water. You can pour water from any barrel into any other barrel in any amounts.

翻译中…

However, to pour water, you must physically handle the barrel from which you are pouring, so if that happens to be the poisonous barrel, you will die. This outcome must be avoided.

翻译中…

However, you can pour water into the poisonous barrel without touching it.

翻译中…

In other words, you can choose the numbers $i, j, x$ ($i \neq j, 1 \leq i, j \leq n, 0 \lt x \leq a_i$, the barrel numbered $i$ is not poisonous) and execute $a_i := a_i - x$, $a_j := a_j + x$. Where $x$ is not necessarily an integer.

翻译中…

Is it possible to guarantee the identification of which barrel contains the poison and remain alive using pouring and the information from the scales? You know that the poison is located on exactly one of the barrels.

翻译中…

Additionally, we ask you to process $q$ queries. In each query, either one of the existing barrels is removed, or an additional barrel with a certain amount of water is added. After each query, you need to answer whether it is possible to guarantee the identification of the poisonous barrel, given that there is exactly one.

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $q$ ($1 \le n, q \le 2 \cdot 10^5$).

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^6$) — the volumes of water in the existing barrels.

翻译中…

The next $q$ lines contain queries, one per line. Each query is either of the form + x or - x, which means, respectively, adding and removing a barrel with $x$ kilograms of water. It is guaranteed that when the query - x is made, one of the existing barrels has a volume of $x$, and that there is always at least one barrel remaining throughout the queries. In all queries, $1 \leq x \leq 10^6$.

翻译中…

Output

翻译中…

Output $q+1$ lines, the answer to the problem before all queries, and after each query. If it is possible to identify the poisonous barrel, output "Yes"; otherwise, output "No". You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

In the first test, before any queries, the weights of the barrels are $[2, 2, 4, 11]$. You can compare the values of the first and second barrels. If the result is not equal, you can definitively conclude that the barrel with the greater weight is poisonous. If the result is equal, both barrels are non-poisonous. Then you can pour all the contents of the first barrel into the second. After that, both the second and third barrels will contain $4$ kilograms of water. Now let's compare the values of the second and third barrels. If the result is not equal, the barrel with the greater weight is poisonous. Otherwise, both barrels are non-poisonous. The only barrel that could be poisonous is barrel 4. Thus, with this strategy, we can safely determine the poisonous barrel.

翻译中…

样例

Input #1
4 7
2 2 4 11
- 2
+ 4
+ 30
+ 40
- 4
+ 2
+ 2
Output #1
Yes
No
Yes
No
Yes
No
No
Yes
InputCopy OutputCopy
Input #2
6 7
5000 1000 400 400 100 99
+ 1
- 5000
- 1
- 400
- 400
- 100
- 99
Output #2
No
Yes
Yes
Yes
No
No
No
Yes
InputCopy OutputCopy
题目信息
题号
2066E
时间限制
4 s
内存限制
1024 MB
标签
二分
数据结构
贪心
模拟

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