Difficulty Level : Medium
Submissions : 148
Asked In :
Marks :15
: 1 | : 1
Takahashi has many balls, on which nothing is written, and one bag. Initially, the bag is empty. Takahashi will do $$$Q$$$ operations, each of which is of one of the following three types:
For each $$$1 \le i \le Q$$$, you are given the type $$$P_i$$$ of the $$$i-th$$$ operation and the value of $$$X_i$$$ if the operation is of Type $$$1$$$ or $$$2$$$. Print the integers recorded in the operations of Type $$$3$$$ in order.
The first line contains an integer $$$Q$$$ $$$(1 \le Q \le 2 \cdot 10^5)$$$ — the number of queries.
The next $$$Q$$$ lines describe the queries. $$$(1 \le P_i \le 3)$$$ and $$$(1 \le X_i \le 10^9)$$$.
If $$$P_i=3$$$, the bag contains at least one ball just before the $$$i-th$$$ operation.
For each operation with $$$P_i=3$$$ among the $$$Q$$$ operations, print the recorded integer in its own line.
5 1 3 1 5 3 2 2 3
3 7
Takahashi will do the following operations.
Therefore, we should print $$$3$$$ and $$$7$$$, in the order they are recorded.
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.