Question: 1. Efficient Janitor The janitor of a high school is extremely efficient. By the end of each day, all of the school's waste is



1. Efficient Janitor The janitor of a high school is extremely efficient. By the end of each day, all of the school's waste is in plastic bags weighing between 1.01 pounds and 3.00 pounds. All plastic bags are then taken to the trash bins outside. One trip is described as selecting a number of bags which together do not weigh more than 3.00 pounds, dumping them in the outside trash can and returning to the school. Given the number of plastic bags n, and the weights of each bag, determine the minimum number of trips the janitor has to make. Example n = 5 weight = [1.01, 1.99, 2.5, 1.5, 1.01] The janitor can carry all plastic bags out in 3 trips: [1.01 +1.99, 2.5, 1.5 +1.01]. Function Description Complete the function efficientjanitor in the editor below. efficientjanitor has the following parameter(s): float weight[n]: weights of the bags Returns int: the minimum number of trips required Constraints 1 n 1000 1.01 weight[i] 3.0 Input Format For Custom Testing The first line contains an integer, n, the number of elements in weight. Each line i of the n subsequent lines (where 0i Sample Case 1 Sample Input For Custom Testing Function STDIN 4 weight [] size n = 4 1.01 weight = [1.01. 1.991, 1.32, 1.4] 1.991 1.32 1.4 Sample Output 3 Explanation The janitor can carry all plastic bags out in 3 trips: The 1st and 2nd plastics bags separately and the 3rd and 4th together
Step by Step Solution
3.51 Rating (154 Votes )
There are 3 Steps involved in it
We use Scanner class to take user input The function void readBagsWeight take user input the weights ... View full answer
Get step-by-step solutions from verified subject matter experts
