Vanya needs to count the number of unacceptable integers for the picked set S.    Vanya plans to attempt various sets S. He needs you to compose a program that tracks down the number of inadmissible integers for the underlying set S, and after each change to the set S. Vanya will make q changes to the set, and each change is one of the accompanying two sorts:

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question

Correct answer will be upvoted else downvoted. Computer science.

 

 Vanya needs to count the number of unacceptable integers for the picked set S. 

 

Vanya plans to attempt various sets S. He needs you to compose a program that tracks down the number of inadmissible integers for the underlying set S, and after each change to the set S. Vanya will make q changes to the set, and each change is one of the accompanying two sorts: 

 

add another integer a to the set S, or 

 

eliminate some integer a from the set S. 

 

Input 

 

The principal line contains two integers n, q (1≤n,q≤200000) — the size of the underlying set S and the number of changes. 

 

The following line contains n particular integers s1,s2,… ,sn (1≤si≤1013) — the underlying components of S. 

 

Every one of the accompanying q lines contain two integers ti, computer based intelligence (1≤ti≤2, 1≤ai≤1013), depicting a change: 

 

In the event that ti=1, an integer simulated intelligence is added to the set S. It is ensured that this integer is absent in S before this activity. 

 

On the off chance that ti=2, an integer computer based intelligence is eliminated from the set S. In is ensured that this integer is available in S before this activity. 

 

Output 

 

Print q+1 lines. 

 

In the principal line print the number of unacceptable integers for the underlying set S. In the following q lines print the number of unsatisfactory integers for S after each change.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr