TCS
is working on a new project called "TestVita". There are N modules
in the project. Each module (i) has completion time denoted in
number of hours (Hi) and may depend on other
modules. If Module x depends on Module y then
one needs to complete y before x.
As Project manager, you are asked to deliver the project as early as possible.
Provide an estimation of amount of time required to complete the project.
Input
Format:
First line contains T, number of test cases.
For each test case:
1.
First
line contains N, number of modules.
2.
Next N lines,
each contain:
o
(i) Module ID
o
(Hi) Number of hours it takes to complete
the module
o
(D) Set of module ids that i depends
on - integers delimited by space.
Output
Format:
Output the minimum number of hours required to deliver the project.
Constraints:
1.
1 <= T <= 10
2.
0 < N < 1000; number of modules
3.
0 < i <= N; module ID
4.
0 < Hi < 60; number of hours it takes to complete the
module i
5.
0 <= |D| < N; number of dependencies
6. 0 < Dk <= N; module ID of dependencies
|
SNo. |
Input |
Output |
|
1 |
|
|
Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Participants submitting solutions in C language should not use functions from
For C and C++, return type of main() function should be int.


0 Comments