Hi, there! Firstly, thank you all in advance for helping me on distributing the gifts. But it wont be that straightforward because I have various gifts to distribute to different regions. I will explain the properties of gifts and how we will distribute them. Santa Claus Expresses and Santa Clauss reindeers will help us but unfortunately, they can carry gifts as much as their capacities. Therefore, in some cases, it will be impossible to deliver all gifts to their owners. At this point, I need your help. Can you help me to figure out the minimum number of gifts that cant be delivered?
1 Details
There are two kinds of regions, which we call the green region and the red region. Therefore, trains and reindeers can be classified as those going to the green region and the red region.
Our gifts are in the bags, and we should distribute them to trains and reindeers according to the properties of the bag. You can consider that the same type of gifts is in the same bag, and we want to distribute them properly.
Properties of bags are as follow, remark that one bag has more than one property
- Each of the gifts in this bag type should be distributed through different vehicles,
i.e. there are no 2 gifts from the same bag on the same train or reindeer.
- Each of the gifts in this bag type should only be distributed to green regions.
- Each of the gifts in this bag type should only be distributed to red regions.
- Each of the gifts in this bag type should only be distributed by train.
- Each of the gifts in this bag type should only be distributed by reindeer. If its not specified, assume that gifts can be distributed to all regions, and both by train and reindeer.
Lets look at some examples of bag types.
- bd can be distributed only by trains which go to green regions
- ace can be distributed only by reindeers which go to red regions and there are no 2 gifts from this bag on the same reindeer
- c can be distributed only to red regions, both by trains and reindeers o d can be distributed only by trains, to both the red and the green regions o a only constraint is that there are no 2 gifts from this bag on the same vehicle o bc invalid, it wont be given as an input to you because it is a contradictory o de invalid, it wont be given as an input to you because it is a contradictory
2 Input & Output
2.1 Input
- The first line represents the number of Santa Claus Expresses that are going to the green region.
- The second line will give the capacities of each of these trains.
- The third line represents the number of Santa Claus Expresses that are going to the red region.
- The fourth line will give the capacities of each of these trains.
- The fifth line represents the number of Santa Clauss reindeers that are going to the green region.
- The sixth line will give the capacities of each of these reindeers.
- The seventh line represents the number of Santa Clauss reindeers that are going to the red region.
- The eighth line will give the capacities of each of these reindeers.
- The ninth line represents the number of bags.
- The tenth line will give the type of bags and number of gifts in it.
2.2 Output
- For each test case, there will be one line output that gives the minimum possible number of gifts that cant be distributed.
2.3 Java Project Outline
Your java project will be named Project4. Your entry class for the project will be named project3main. All your .java files will be under folder Project4/src. Your project should be compatible with Java 16. Your program will be compiled with the below command:
javac Project4/src/*.java -d Project3/bin release 16
The input and output files can be in any folder. Design your code in order to accept the full path for file arguments. Your program will be run with the below command:
java project4main <inputfile> <outputfile>
Make sure that your final submission compiles and runs with these commands.
Sample Input File | Explanations |
1321 90 124ac 6 be 3 cd 4 ad 8 | The number of trains go to green regionCapacity of each trainThe number of trains go to red regionCapacity of each trainThe number of reindeers go to green regionIf there is no such reindeer this line will be emptyThe number of reindeers go to red regionCapacity of each reindeersThe number of gift types i.e number of bagsTypes of bags and numbers of gifts in them respectively |
The maximum possible number of gifts that can be distributed is 9. The total number of gifts is 21. Therefore, the minimum possible number of gifts that cannot be given is 12.
Sample Output File | Explanations |
12 | The number of gifts that cannot be distributed |
Reviews
There are no reviews yet.