Adventurer on a Quest
Time limit3sMemory limit256 MB
Maintain a set of completed quest numbers under insertions and range queries asking how many integers in [L, R] are not yet completed.
- Level
Medium6 of 10
- Topics
- Hash map, Sorting, Binary search, Implementation
- Solved
- No attempts yet
Problem
An adventurer is a ranked player in the online RPG World Art Yggdrasil (WAY) and enjoys completing quests every day.
WAY has one quest for every integer number from to . Completing every quest in certain ranges earns achievements.
Quests cannot always be completed in order, so the number of remaining quests has to be computed for each achievement. An addon tracks the completion record and reports how many quests in a given range are still incomplete.
Given the completion record and the requests, write a program that answers every lookup request.
Input
The first line gives , the number of quests completed so far.
The second line gives the completed quest numbers .
The third line gives , the number of requests.
Each of the following lines gives one request.
- : the quest numbered has been completed. Record it.
- : print the number of quests numbered from to inclusive that are still incomplete.
Output
For each request of type , print the number of incomplete quests satisfying the condition, one per line.