시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 35 | 8 | 8 | 32.000% |
One of the programming paradigm in parallel processing is the producer/consumer paradigm that can be implemented using a system with a "manager" process and several "client" processes. The clients can be producers, consumers, etc. The manager keeps a trace of client processes. Each process is identified by its cost that is a strictly positive integer in the range 1 .. 10000. The number of processes with the same cost cannot exceed 10000. The queue is managed according to three types of requests, as follows:
There are two manager policies:
The manager will print the cost of a removed process only if the ordinal number of the removed process is in the removal list.
Your job is to write a program that simulates the manager process.
Each data set in the input has the following format:
Each data set ends with an e request. The data sets are separated by empty lines.
The program prints on standard output the cost of each process that is removed, provided that the ordinal number of the remove request is in the list and the queue is not empty at that moment. If the queue is empty the program prints -1. The results are printed on separate lines. An empty line separates the results of different data sets.
5 2 1 3 a 2 a 3 r a 4 p 2 r a 5 r e
2 5
ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2002 F번