#K3706. Process Scheduler Simulation
Process Scheduler Simulation
Process Scheduler Simulation
This problem involves simulating a simple process scheduler. The scheduler receives a series of events from standard input, where each event is one of the following commands:
- NEW p t: Adds a new process with integer priority p (1 ≤ p ≤ 100) and unique process id t. In this system, a lower numeric value means a higher priority.
- RUN: Executes the next process based on the scheduling rules.
- END: Signals the end of input.
When a RUN command is received, the process with the highest priority (i.e. the lowest numerical value) is selected. In case of a tie in priority, the process that was added earlier is executed first. If there is no process waiting when a RUN command is encountered, output "NO PROCESS".
inputFormat
Input is provided via standard input (stdin) as a sequence of lines. Each line represents an event: either "NEW p t" to add a process, "RUN" to execute the next process, or "END" to terminate input.
outputFormat
For every RUN event, output the process id to be executed or "NO PROCESS" if there are no processes available. Each output should be printed on a separate line in standard output (stdout).
## sampleNEW 10 1
NEW 5 2
NEW 10 3
RUN
RUN
RUN
RUN
END
2
1
3
NO PROCESS
</p>