ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > CEN112 Questions 2016 > задача:


15-PE2-6. 50985 - Books Waiting

CEN112 Questions 2016

Старт: 30.мар.2016 в 15:10:22
Финиш: 01.апр.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (1)

Задачи турнира

• 15-PE-7. 50871 - Harmonic Mean
• 15-PE-8. 50872 - Top M Grades
• 15-PE2-1. 50980 - The smallest rect...
• 15-PE2-2. 50981 - Top popular m-st...
• 15-PE2-2. 50984 - Top m hardworki...
• 15-PE2-2. 51086 - Top popular student
• 15-PE2-3. 50982 - A thief in labyrinth
• 15-PE2-4. 50983 - Course Selection
• 15-PE2-6. 50985 - Books Waiting
• 15-PE2-8. 50987 - Very Looong Queue
• 15-RE-2. 50999 - Overlapping Trips
• 3. 51002 - The most successful classes
• 4. 51003 - Double Prime
• HW092. 51081 - Fish Pond I
• HW092. 51062 - Fish Pond II

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Books Waiting

Question: The library is moving to the new facility. At the same time, the administration wants to record the books to the new library program system. They bring bunch of books all the time and put them to the registration office desk. The registration officer, takes the books one by one and registers them to the system (remove from the stack). Write a program, that reads a list and a sequence of instructions. Then show the final list after following the instructions.

Input specification
You will be given an integer in the beginning (n) the number of instructions. Every instruction listed in a line and starts with a letter P (Place new books to the desktop) or R (Remove books from the desktop):

  • After the letter P: you are given a number m: the number of new books. Then, you are given the IDs of m new books that have just arrived.
  • After the letter R: you are given a number k, The officer have recorded k books from the top of the lists (removed from the stack of books).
where 0 ≤ n ≤ 5,000 and 0 ≤ m ≤ 100

Output specification:
Show the IDs of the books still waiting on the desktop. Show a zero "0" if there is no book waiting.

Sample Input I
4
P 3 11 76 5
R 1
P 2 13 58
R 2
Sample Input 2
7
P 5 68 3 10 100 99
P 6 28 4 33 47 80 15
R 6
R 2
P 3 26 9 61
R 4
P 3 59 52 53
Sample Output I
76 11
Sample Output 2
53 52 59 3 68

Explanation: There 4 instructions. The first instruction tells to place 3 books to desktop. Then one book is removed (book with the ID 5). Then two new books are placed to the desktop. And then two books have been recorded and removed by the officer. So, there are only two books waiting on the desktop: books 76 and 11.



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

www.contester.ru