Answered step by step
Verified Expert Solution
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 and from there you can choose other classes that have class 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, means that node is connected to node or you need to take class to take class The last line of input are the number of units that each class will give you.
Constraints
N M
U
Output Format
The maximum units that you can take.
Sample Input
Sample Output
Explanation
are the classes with units that result in the highest total units of
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started