TestVita
Problem:
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.
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:
First line contains T, number of test cases.
For each test case:
- First line contains N, number of modules.
- Next N lines, each contain:
- (i) Module ID
- (Hi) Number of hours it takes to complete the module
- (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 | 1 5 1 5 0 2 6 1 3 3 2 4 2 3 5 1 3 | 16 |
Program:
#include <stdio.h>
int main() {
int n,m[10],t[10],d[10],q,a,i,sum=0;
scanf("%d",&a);
for(q=1;q<=a;q++)
{
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&m[i],&t[i],&d[i]);
for(i=0;i<n-1;i++)
{
if(d[i]==d[i+1])
{
if(t[i]<t[i+1])
t[i]=0;
else
t[i+1]=0;
}
}
for(i=0;i<n;i++)
{
sum=sum+t[i];
}
printf("%d",sum);
}
return 0;
}
Output:
1
5
1 5 0
2 6 1
3 3 2
4 2 3
5 1 3
16
You can also run it on an online IDE: https://ide.geeksforgeeks.org/eTqOGzjCr5
Your feedback are welcomed! If you have any doubts you can contact me or comment below! Cheers!
Related Link: Bank Compare
5
1 5 0
2 6 1
3 3 2
4 2 3
5 1 3
16
You can also run it on an online IDE: https://ide.geeksforgeeks.org/eTqOGzjCr5
Your feedback are welcomed! If you have any doubts you can contact me or comment below! Cheers!
Related Link: Bank Compare
ReplyDeleteThank you so much for all the wonderful information about Technology! I love your work.
C C++ Training in Chennai
c++ courses in chennai
C++ Training in Chennai
C C++ Training in OMR
core java training in chennai
javascript training in chennai
SAS Training in Chennai
QTP Training in Chennai
You should be a part of a contest for one of the greatest sites online. Technology I will highly recommend this website!
ReplyDeleteThank you
DeleteOutstanding blog, in my opinion site owners should acquire a great deal out of this blog its very user welcoming.
ReplyDeleteC and C++ Training Institute in chennai | C and C++ Training Institute in anna nagar | C and C++ Training Institute in omr | C and C++ Training Institute in porur | C and C++ Training Institute in tambaram | C and C++ Training Institute in velachery
A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.
ReplyDeletePTE institute in ambala
Best PTE Coaching in ambala
IELTS Institute in Ambala