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

建议使用的浏览器:

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

1096:Chores

题目描述
Farmer John's family pitches in with the chores during milking, doing all the chores as quickly as possible. At FJ's house, some chores cannot be started until others have been completed, e.g., it is impossible to wash the cows until they are in the stalls.

Farmer John has a list of N (3 <= N <= 10,000) chores that must be completed. Each chore requires an integer time (1 <= length of time <= 100) to complete and there may be other chores that must be completed before this chore is started. We will call these prerequisite chores. At least one chore has no prerequisite: the very first one, number 1. Farmer John's list of chores is nicely ordered, and chore K (K > 1) can have only chores 1,.K-1 as prerequisites. Write a program that reads a list of chores from 1 to N with associated times and all perquisite chores. Now calculate the shortest time it will take to complete all N chores. Of course, chores that do not depend on each other can be performed simultaneously.
输入解释
* Line 1: One integer, N

* Lines 2..N+1: N lines, each with several space-separated integers. Line 2 contains chore 1; line 3 contains chore 2, and so on. Each line contains the length of time to complete the chore, the number of the prerequisites, Pi, (0 <= Pi <= 100), and the Pi prerequisites (range 1..N, of course).
输出解释
A single line with an integer which is the least amount of time required to perform all the chores.
输入样例
7
5 0
1 1 1
3 1 2
6 1 1
1 2 2 4
8 2 2 4
4 3 3 5 6
输出样例
23
提示

[Here is one task schedule:

Chore 1 starts at time 0, ends at time 5.
Chore 2 starts at time 5, ends at time 6.
Chore 3 starts at time 6, ends at time 9.
Chore 4 starts at time 5, ends at time 11.
Chore 5 starts at time 11, ends at time 12.
Chore 6 starts at time 11, ends at time 19.
Chore 7 starts at time 19, ends at time 23.
]


该题目包含在题集 ACM赛制

题目来源 USACO 2002 February

共提交 12

通过率 16.67%
时间上限 内存上限
3000 MS 30 MB