当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2448:A New Operating System

题目描述
May is a lovely girl. Due to her filial piety, she wants to give a present on her mother's birthday. Because both her parents are the top programmer in the world, she decided to design a new program, a special program that is an Operating System! With the help of her excellent programming skill, May has already finished the kernel of the new OS. And the birthday is coming, she is afraid that time is not enough to finish the entire project in time. As her best net-pal, it's your duty to help her.
This is a multitask OS, processes run at the same time. There are following command in the OS:

CreateProcess(PID,Memory,Priority)
A new process is created with the process identification PID and memory size, and a priority. The priority in this command is called outer priority of a process.

AddMessage(PID,Priority)
That means, add a new message to the message queue of process PID, with the priority of Priority. The message with higher Priority will run earlier that lower ones. The Priority is called inner priority.

Run
Find out the message with biggest HP. HP is defined as the product of the inner priority of a message and the corresponding process priority. If two or more messages have the same HP, the one with smallest PID will run first. Print the information "Run: HP" to the output file, HP will be replaced by the message HP you found, or print "Empty" instead if the message queue is empty. Finally remove this message if exist.

ChangePriority(PID,NewValue)
Change the outer priority of process PID to NewValue.

GetMemory(PID,Memory)
Process PID memory increases the amount of Memory.

FreeMemory(PID,Memory)
Process PID memory decreases the amount of Memory.

RunProcess(PID)
Similar with Run command. Find out the message in the process PID message queue, print the information "Run Process: Priority" to the output file, Priority will be replaced by the message priority you found, or print "Empty" instead if the message queue is empty. Finally remove this message if exist.

CloseMaxMemory
Find out the process that used the largest number of memory and close it if exists (if tie, the one with smallest PID should be release first), or print "Empty" instead.

CloseProcess(PID)
Close the process with the identification of PID.

Whenever a process' memory is less than or equal to 0, it will be close automatically. In any of the above commands except the first one, if the PID doesn't exist, please print an "Error" to the output. For the first command, if the PID is already exist, print an "Error" and ignore this command.
输入解释
First line in the input is an integer number N (1 <= N <= 100000), which represents the number of commands. The next N lines, each gives a command described above. Any number given in the input file will be non-negative integer and will not be more than 1000000000.
输出解释
The output format has been described above.
输入样例
11
CloseMaxMemory
CreateProcess(1,100,1)
CreateProcess(2,200,1)
CreateProcess(3,300,1)
AddMessage(1,9)
AddMessage(2,19)
AddMessage(1,10)
GetMemory(2,999)
CloseMaxMemory
Run
RunProcess(1)
输出样例
Empty
Run: 10
Run Process: 9
提示
The total size of the input files may be as large as 21.8MB.
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 5000MS

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 POJ Monthly,Minkerui

源链接: POJ-2448

最后修改于 2020-10-29T06:32:46+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000 65536