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

建议使用的浏览器:

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

1616:Harmonic Periods

题目描述
In real-time scheduling, predictability is very important, i.e., we would like to know the whole schedule before we really run the tasks. Rate-monotonic scheduling is very popular in real-time scheduling for periodic tasks, where tasks with shorter periods have higher priority. However, it is still dicult to know the start time and finish time of each task and they might be di erent in each period, especially for tasks with low priority, i.e. long period. The hyperperiod, the least common multiple of all periods,is usually too big to be practical to describe the whole schedule. However, if the task periods are harmonic, i.e. are multiples, it is possible to find the start time and finish time of each task quickly because the schedule becomes more regular.

Figure 1 shows that periodic tasks T1, T2, T3, T4 with execution times 1, 1, 3, 1 and periods 2, 4, 16, 32 respectively are schedulable, each task finishes execution in its period, using the Rate-Monotonic scheduling algorithm since T1, T2, T3, T4 finish execution at time 1, 2, 12, 16 respectively. T3 is preempted by T1 and T2 at time 4 and time 8 and resume at time 7 and time 11.
输入解释
All the input numbers are positive integers, < 500000, separated by a space or new line. The first line is the number of task sets. Then, the task sets are listed set by set. Each task set is listed by a line of the number of tasks, <= 100, and lines of task execution time and period pairs, execution time < period. The periods are harmonic, not sorted, and are different in a task set.
输出解释
For each task set, find and print out the finish time of the task with the largest period using rate-monotonic scheduling, if schedulable; otherwise print out -1.
输入样例
3
4
1 2
1 4
3 16
1 32
3
1 4
4 8
256 1024
3
1 2
3 8
1 4
输出样例
16
1024
-1

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

题目来源 Asia Kaohsiung 2003

源链接: POJ-1616

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

共提交 0

通过率 --%
时间上限 内存上限
1000 10000