#P1500E. Subset Trick
Subset Trick
No submission language available for this problem.
Description
Vanya invented an interesting trick with a set of integers.
Let an illusionist have a set of positive integers . He names a positive integer . Then an audience volunteer must choose some subset (possibly, empty) of without disclosing it to the illusionist. The volunteer tells the illusionist the size of the chosen subset. And here comes the trick: the illusionist guesses whether the sum of the subset elements does not exceed . The sum of elements of an empty subset is considered to be .
Vanya wants to prepare the trick for a public performance. He prepared some set of distinct positive integers . Vasya wants the trick to be successful. He calls a positive number unsuitable, if he can't be sure that the trick would be successful for every subset a viewer can choose.
Vanya wants to count the number of unsuitable integers for the chosen set .
Vanya plans to try different sets . He wants you to write a program that finds the number of unsuitable integers for the initial set , and after each change to the set . Vanya will make changes to the set, and each change is one of the following two types:
- add a new integer to the set , or
- remove some integer from the set .
The first line contains two integers , () — the size of the initial set and the number of changes.
The next line contains distinct integers () — the initial elements of .
Each of the following lines contain two integers , (, ), describing a change:
- If , then an integer is added to the set . It is guaranteed that this integer is not present in before this operation.
- If , then an integer is removed from the set . In is guaranteed that this integer is present in before this operation.
Print lines.
In the first line print the number of unsuitable integers for the initial set . In the next lines print the number of unsuitable integers for after each change.
Input
The first line contains two integers , () — the size of the initial set and the number of changes.
The next line contains distinct integers () — the initial elements of .
Each of the following lines contain two integers , (, ), describing a change:
- If , then an integer is added to the set . It is guaranteed that this integer is not present in before this operation.
- If , then an integer is removed from the set . In is guaranteed that this integer is present in before this operation.
Output
Print lines.
In the first line print the number of unsuitable integers for the initial set . In the next lines print the number of unsuitable integers for after each change.
Samples
Note
In the first example the initial set is . For this set the trick can be unsuccessful for . For example, if , the volunteer can choose the subset with sum , and can choose the subset with sum . However, in both cases the illusionist only know the same size of the subset (), so he can't be sure answering making a guess. Since there is only one subset of size , and the sum of each subset of smaller size does not exceed , all are suitable.