Central Library
Practice
5 (1 votes)
Easy
Problem
46% Success 213 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

It is starting of the semester and central library of NIT silchar decided to distribute the books. So all the students from different years went to collect the books , librarian has a strange rule he will give book to student of that year whose total student currently present in library is maximum , in case of tie student of higher year will get book. Each student can be uniquely identified by pair (Year , scholar number). At any instant , student having higher scholar id from particular year (whose total student currently present is maximum) will receive book.

There are two types of query
type 1 : At this time student of year "Y" and scholar id "S" enters to the library.
type 2: You have to print year "Y" and scholar id "S" of student who will receive the book from librarian.

Input:
first line of input is Q representing total number of queries. Next Q lines will be query of type 1 or type 2.

Output: C for query of type 2 print Year Y and scholar number S of student who will receive book at this moment.

Note: All (Y,S) pair are unique.

Constraints:
1 <= Q <= 105
1 <= Y <= 4
1 <= S <= 105

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
4 votes
Tags:
Easy
Editorial

No editorial available for this problem.