There are N houses (numbered from 0 to N-1) along a street. In each of them,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
There are N houses (numbered from 0 to N-1) along a street. In each of them, recyclable trash (plastic, glass, metal) is collected into separate bags. There are three trucks that collect the trash. Each of them collects a separate type of trash (the first collects plastic, the second, glass and the third, metal). All the trucks begin and end their jobs at the starting end of the street. Passing from the starting point to house number 0 takes D[0] minutes. Passing between houses number K-1 and K (for K in the range 1 to N-1) takes D[K] minutes. Loading one bag onto the truck takes one minute. For example, D = [2, 5] means that passing between the starting point and house number 0 takes 2 minutes and passing between houses number 0 and 1 takes 5 minutes. Each of the houses has already collected some bags (or possibly no bags) of recyclable trash. The number of bags that house number K has collected is recorded in string T[K], composed of letters 'P' (plastic), 'G' (glass) and 'M' (metal). For example, T[1] = "GMG" means that house number 1 has collected two bags of glass and one bag of metal. Each house may collect more than one bag of each type. All of the trucks start their jobs simultaneously. Each finishes its job after collecting all of the bags of the given type of trash and returning back to the starting point. What is the minimum number of minutes that will pass before all the trucks finish all the jobs? Write a function: class Solution public int solution (int [] D, String [] T); } that, given array D of N integers and array T of N strings, returns the minimum number of minutes needed by the trucks to finish I the jobs. Examples: 1. Given D= [2, 5], T = ["PGP", "M"], the function should return 15. The truck collecting plastic needs to go to house number 0, collect two bags and go back, which takes 2+1 +1 +2 = 6 minutes. The truck collecting glass needs 5 minutes: 2 minutes to go to house number 0, 1 minute to collect a bag and 2 minutes to return to the starting point. The truck collecting metal will go straight to house number 1, collect a bag and go back in 7 + 1 + 7 = 15 minutes. After 15 minutes all of the trash will have been collected and all trucks will have returned to the starting point. start PGP There are N houses (numbered from 0 to N-1) along a street. In each of them, recyclable trash (plastic, glass, metal) is collected into separate bags. There are three trucks that collect the trash. Each of them collects a separate type of trash (the first collects plastic, the second, glass and the third, metal). All the trucks begin and end their jobs at the starting end of the street. Passing from the starting point to house number 0 takes D[0] minutes. Passing between houses number K-1 and K (for K in the range 1 to N-1) takes D[K] minutes. Loading one bag onto the truck takes one minute. For example, D = [2, 5] means that passing between the starting point and house number 0 takes 2 minutes and passing between houses number 0 and 1 takes 5 minutes. Each of the houses has already collected some bags (or possibly no bags) of recyclable trash. The number of bags that house number K has collected is recorded in string T[K], composed of letters 'P' (plastic), 'G' (glass) and 'M' (metal). For example, T[1] = "GMG" means that house number 1 has collected two bags of glass and one bag of metal. Each house may collect more than one bag of each type. All of the trucks start their jobs simultaneously. Each finishes its job after collecting all of the bags of the given type of trash and returning back to the starting point. What is the minimum number of minutes that will pass before all the trucks finish all the jobs? Write a function: class Solution public int solution (int [] D, String [] T); } that, given array D of N integers and array T of N strings, returns the minimum number of minutes needed by the trucks to finish I the jobs. Examples: 1. Given D= [2, 5], T = ["PGP", "M"], the function should return 15. The truck collecting plastic needs to go to house number 0, collect two bags and go back, which takes 2+1 +1 +2 = 6 minutes. The truck collecting glass needs 5 minutes: 2 minutes to go to house number 0, 1 minute to collect a bag and 2 minutes to return to the starting point. The truck collecting metal will go straight to house number 1, collect a bag and go back in 7 + 1 + 7 = 15 minutes. After 15 minutes all of the trash will have been collected and all trucks will have returned to the starting point. start PGP
Expert Answer:
Answer rating: 100% (QA)
There are N houses numbered from 0 to N1 along a street In each of them recyclable trash plastic glass metal is collected into separate bags There are ... View the full answer
Related Book For
Mathematical Interest Theory
ISBN: 9781470465681
3rd Edition
Authors: Leslie Jane, James Daniel, Federer Vaaler
Posted Date:
Students also viewed these accounting questions
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Ava bought a house on 1 July 2000 for 62,000. She occupied the entire property as her PPR until 1 August 2007 when she began using one-quarter of the house for business purposes. This continued until...
-
A 380-mL spherical flask contains 0.065 mol of an ideal gas at a temperature of 283 K. What is the average force exerted on the walls of the flask by a single molecule?
-
The reaction 2 NO(g) + CI2(g) 2 NOCI(g) was performed and the following data obtained: Is the following mechanism consistent with the data? Explain NO(g) + CI2(g) NOCI2(g) NOCI2(g) + NO(g) 2 NOCI(g)?...
-
The data in Table B. 5 present the performance of a chemical process as a function of several controllable process variables. a. Fit a multiple regression model relating $\mathrm{CO}_{2}$ product...
-
An 8.00-kg ball, hanging from the ceiling by a light wire 135 cm long, is struck in an elastic collision by a 2.00-kg ball moving horizontally at 5.00 m/s just before the collision. Find the tension...
-
Mountain Air Limited manufactures a line of room air purifiers. Management is currently evaluating the possible production of an air purifier for automobiles. Based on an annual volume of 1 0 , 0 0 0...
-
Explain the two approaches of packet switching techniques.
-
The 1500 kg SUV shown below is at the bottom of a valley. The valley can be thought of as part of a circular path with a radius of 85 m, as indicated in the diagram. 8. i At the bottom of the valley,...
-
Determine the mass of a satellite that is orbiting the earth at 2983.5 km above its surface, if the satellite experiences a force of 1620 N to keep it in orbit. (the e4 means the same as x104) a. 221...
-
12. 3 8 Suppose f(x)dx = 4, [ f(x)dx = -7, and g(x)dx = 5. Evaluate the integrals in parts a - d. 0 3 3 3 a ste [5f(x) dx = [ (Type an integer or a decimal.) 8 b. -2g(x) dx = [ (Type an integer or a...
-
The figure shows three identical, thin, long, perpendicular rods. The rods are numbered, each with a length of 100 and a mass of = 0.50 m. They are placed on the three axes 2. Connected to one of the...
-
Find the number of IR-active CO stretching modes for trans-[FeCl2(CO)4]. What's the determination of the reducible representation, perform the decomposition, and assign which vibrations are IR active.
-
3-5 Margie Van Epps established Health Services, P.C., a professional corporation, in March of the current year. Health Services offers healthy living advice to its clients. The effect of each...
-
From 1970 to 1990, Sri Lanka's population grew by approximately 2.2 million persons every five years. The population in 1970 was 12.2 million people.What is the best formula for P, Sri Lanka's...
-
Find the area of the shaded region. The graphs depict IQ scores of adults, and those scores are normally distributed with a mean of 100 and a standard deviation of 15 (as on the Wechsler test). 118
-
Find the area of the shaded region. The graphs depict IQ scores of adults, and those scores are normally distributed with a mean of 100 and a standard deviation of 15 (as on the Wechsler test). 91
-
Construct the confidence interval that could be used to test the claim in Exercise 1. What feature of the confidence interval leads to the same conclusion from Exercise 1? Data From Exercise 1: In...
-
On May 10, Chen Co. issues 2,000 6 par value ordinary shares for cash at 13 per share. Journalize the issuance of the shares.
-
Which of the following is true? a. In the United States, the primary corporate shareholders are financial institutions. b. Share capital means total assets under GAAP. c. Under both IFRS and GAAP,...
-
Under GAAP, the amount of capital received in excess of par value would be credited to: a. Retained Earnings. b. Paid-in Capital in Excess of Par. c. Share Premium. d. Par value is not used under...
Study smarter with the SolutionInn App