6
28
2014
7

1216: [HNOI2003]操作系统

rank1纪念

1216: [HNOI2003]操作系统

Time Limit: 10 Sec  Memory Limit: 162 MB
Submit: 337  Solved: 166
[Submit][Status]

Description

写一个程序来模拟操作系统的进程调度。假设该系统只有一个CPU,每一个进程的到达时间,执行时间和运行优先级都是已知的。其中运行优先级用自然数表示,数字越大,则优先级越高。如果一个进程到达的时候CPU是空闲的,则它会一直占用CPU直到该进程结束。除非在这个过程中,有一个比它优先级高的进程要运行。在这种情况下,这个新的(优先级更高的)进程会占用CPU,而老的只有等待。如果一个进程到达时,CPU正在处理一个比它优先级高或优先级相同的进程,则这个(新到达的)进程必须等待。一旦CPU空闲,如果此时有进程在等待,则选择优先级最高的先运行。如果有多个优先级最高的进程,则选择到达时间最早的。

Input

输入文件包含若干行,每一行有四个自然数(均不超过108),分别是进程号,到达时间,执行时间和优先级。不同进程有不同的编号,不会有两个相同优先级的进程同时到达。输入数据已经按到达时间从小到大排序。输入数据保证在任何时候,等待队列中的进程不超过15000个。

Output

按照进程结束的时间输出每个进程的进程号和结束时间

Sample Input

1 1 5 3
2 10 5 1
3 12 7 2
4 20 2 3
5 21 9 4
6 22 2 4
7 23 5 2
8 24 2 4

Sample Output

1 6
3 19
5 30
6 32
8 34
4 35
7 40
2 42

HINT

 

Source

正如题目说的,模拟+堆

堆维护当前时间之前要运行的优先级

对于一个进程,在它之前的时间一定与它无关,用堆维护,模拟

然后把它放进堆

果然手写的堆比系统堆快多了

加个读入优化就rank1了……果然神犇们不想刷水题的rank吗?

代码不放了。。。

用的斜堆。。。

Category: BZOJ | Tags: | Read Count: 1141
mega888 apk 说:
2021年8月30日 00:42

Hmm… I interpret blogs on a analogous issue, however i never visited your blog. I added it to populars also i’ll be your faithful primer.

admin 说:
2021年11月28日 20:11

If you want to solve mathematical problems. You are don't worry about that problems. You solve your problems by ASUS VivoBook 15 Thin & Light Laptop. This laptop has many solving features.You choose such product by clicking here. https://primeelectrolite.com

admin 说:
2021年11月28日 20:14

 If you want to solve mathematical problems. You are don't worry about that problems. You solve your problems by ASUS VivoBook 15 Thin & Light Laptop. This laptop has many solving features.                                                                                                                                                                                               

 

 

AP 10th computer Que 说:
2022年9月11日 02:12

Since the Government of AP also provided Computer labs for students in all Government schools also.Computer Knowledge is very much essential nowadays. Even Checking the Results of various examinations, AP 10th computer Question Paper Downloading hall tickets and study materials for multiple exams and booking tickets etc ..need minimum Technical Knowledge is much more important for everyone. Since the Government of AP also provided Computer labs for students in all Government schools also.

Alyssa 说:
2023年1月07日 20:24

An operating system (OS) is a program that enables a computer to communicate with its hardware and run its programs. Most modern computers use a graphical user interface (GUI), which allows users Lab grown diamonds to interact with the computer using a mouse and keyboard. However, some computers still use a command-line interface (CLI), which requires users to type commands in order to interact with the computer. Each type of interface has its own advantages and disadvantages.

seo service UK 说:
2024年1月07日 22:07

This is the right blog for anybody who wants to search out out about this topic. You realize a lot its virtually arduous to argue with you (not that I actually would need…HaHa). You positively put a new spin on a topic thats been written about for years. Nice stuff, just nice!Thank you for another wonderful article. Wherever else could anyone get that kind of info in this type of an ideal way of writing? I’ve got a presentation next week, and Im round the search for these info.

seo service london 说:
2024年1月13日 22:35

In any game, you depend on the currency of the game to survive and make progress in the virtual world. V bucks are the in-game currency of this giant game. V Bucks are the bane of existence when it comes to the digital world of Fortnite


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com