Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are planning courses that you need to take for a given quarter, but you are behind on units, so you are trying to take

You are planning courses that you need to take for a given quarter, but you are behind on units, so you are trying to take as many as you can. There are M courses offered in one quarter and each course will give you U units. Certain courses can only be taken if their corequisite course is also being taken at the same time. You have to take a certain core class, denoted as class 0, and from there you can choose other classes that have class 0 as a corequisite. Given that you can only take N classes this quarter, determine the maximum number of units you can take.
Input Format
The first line of input is the number of classes you can take followed by the total number of classes. Each line of input afterwards consists of the current node and the node that the node is connected to. For example, 01 means that node 0 is connected to node 1, or you need to take class 0 to take class 1. The last line of input are the number of units that each class will give you.
Constraints
1<= N <= M <=50
0<= U <=10^4
Output Format
The maximum units that you can take.
Sample Input 0
47
01
02
13
14
25
26
1224532
Sample Output 0
12
Explanation 0
0,1,3,4 are the classes with units 1,2,4,5 that result in the highest total units of 12.
please write me a java code for this i seriously need this write in java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+18-4 Describe the loca- tion and function of feature. detectors.

Answered: 1 week ago

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago

Question

Draw and explain the operation of LVDT for pressure measurement

Answered: 1 week ago