Huawei OD Machine Test-Printer Queue-2022Q4 Volume A-Py/Java/JS

There are 5 printers printing files, each printer has its own queue to be printed. Because the contents of the printed files are prioritized,

Therefore, the files in the queue have different generation priorities from 1 to 10, and the larger the number, the higher the priority.

The printer will select the file with the highest priority from its own queue to print.

If there are two files with the same priority, the file that entered the queue first is selected.

Now please come to simulate the printing process of these 5 printers.

enter description

Each input contains 1 test case, and the first line of each test case gives the number N of occurrences (0 < N < 1000).
Next there are N lines, each representing the event that occurred.
There are two kinds of events as follows:
1. "IN P NUM", which means that a file with priority NUM is put in the queue of printer P to be printed. (0< P <= 5, 0 < NUM <= 10);
2. "OUT P", means that printer P has printed a file, and the file is taken out from the queue to be printed at the same time. (0<P<=5).

output description

For each test case, for each "OUT P" event, output the number of the file on one line.
If there is no file to print at this time, please output "NULL".
The file number is defined as the xth occurrence of the "IN P NUM" event, where the number of the file to be printed is x. Numbering starts from 1.

Example 1 The input and output examples are only for debugging, and the background judgment data generally does not include examples

enter

7
IN 1 1
IN 1 2
IN 1 3
IN 2 1
OUT 1
OUT 2
OUT 2

output

3
4
NULL

java code

Guess you like

Origin blog.csdn.net/miao_9/article/details/130235524