HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Non-linear Data structures: Map, Set, Priority Queues > problem:


50987 - Very Looong Queue

Guest
• Review clarifications (1)

Section problems

• 50796 - KNN
• 50795 - Trunk
• 50985 - Books Waiting
• 50995 - Group Average
• 50983 - Course Selection
• 50517 - Confusion Matrix
• 50789 - Number of Cities
• 50993 - Products in store
• 50987 - Very Looong Queue
• 50869 - Birthday Celebration
• 50981 - Top popular m-students
• 50794 - Writing Files Into HDD
• 51000 - Book Index
• 51024 - Total Stock Price
• 51023 - Preparing Keyword Index
• 50706 - The most crowded Club
• 50793 - Top M Customers

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Very Looong Queue

Question: You are given the come and leave instructions for some people. Write a program, that reads a sequence of instructions. Then, show the final list after following the instructions.

Input specification
You will be given an integer in the beginning: the number of instructions (n). Then, in the following n lines you will be given n instructions. Every instruction starts with a letter and followed by a number (N):

  • C N: N people are coming to the end of queue. Then, you will be given the IDs of N people.
  • L N: N people are leaving from the beginning of the queue.
where 0 ≤ n ≤ 10,000 and people IDs are less than 25,000.

Output specification:
Show IDs of the people who are still in the queue. Show -1 if the queue is empty.

Sample Input I
5
C 5 10 16 1 18 11
L 2
L 3
C 4 15 20 13 3
L 2
Sample Input II
5
C 3 17 2 16
L 1
C 5 5 15 3 1 12
C 1 7
L 4
Sample Output I
13 3
Sample Output II
3 1 12 7



Для отправки решений необходимо выполнить вход.

www.contester.ru