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
-
Draft an informal letter/memo addressed to Judge Hodge to go along with the pleadings, kindly showing him whyIn reFeldhausis good law, and why he is mandated to follow it. Our goal here is to avoid...
-
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 hollow cylindrical rod (rod 1) and a solid cylindrical rod (rod 2) are made of the same material. The two rods have the same length and the same outer radius. If the same compressional force is...
-
Figure 11.8 shows that a typical computer system is interconnected with a number of different buses, both internal and external. The diagram includes multiple cache buses, an external CPU bus,...
-
Suppose you're evaluating a stock that just paid a quarterly dividend of $1.25, you expect future dividends on this stock to increase at a rate of 4 percent per quarter, and you think the appropriate...
-
A trader wishes to unwind a position of 200,000 units in an asset over eight days. The dollar bidoffer spread, as a function of daily trading volume q, is a + b cq where a = 0.2, b = 0.15 and c = 0.1...
-
9:45 WeBWorK MAA MATHEMATICAL ASSOCIATION OF AMERICA Logged in as nataliadelgado. Log Out webwork / 2022_spring_napostolakis_mth06_d09/ 3.5_relations_and_functions / 25 3.5 Relations and Function...
-
The average grain diameter for a brass material was measured as a function of time at 650°C, which is tabulated below at two different times: (a) What was the original grain diameter? (b) What...
-
I need answers in at least 2 paragraphs and please cite refrences. refrences are must
-
Kent Products uses a predetermined overhead application rate of $20 per labor hour. A review of the company's accounting records revealed budgeted manufacturing overhead for the year 2022 of...
-
A train with a maximum speed of 105 km/h has an acceleration rate of 0.22 m/s and a deceleration rate of 0.29 m/s. If the train takes 50 s to slow down from maximum speed to a complete stop, how much...
-
Compare and contrast the definitions of outcomes and outputs. Talk about possible measures of outputs and outcomes that you might use in your strategic plan, as relevant to your organization. Include...
-
1) Why might the value of commercial mortgage real estate or CMBS be falling? 2) Explain what is happening in financing markets and why this might have an impact on funds that invest in CRE and CMBS?...
-
What would be good responses for the following? Review eHealth's Form 10-K for the fiscal year ended December 31, 2019 1.) The accounting policy that I think provides the fairest representation of...
-
Colleagues Post: A Brief Description of the Program The foster parent training program for incoming foster parents has the primary goals of reducing foster placement disruptions, improving the...
-
With your classmates, form small teams of skunkworks. Your task is to identify an innovation that you think would benefit your school, college, or university, and to outline an action plan for...
-
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...
-
What disclosures are required in accordance with IAS 16 when a non-current asset is revalued?
-
In what circumstances may an amount be transferred from the revaluation surplus to retained earnings?
-
Golden Foods (GF) Ltd makes pies, pastries and pizzas, which it sells to retailers under its own brand-name and also supplies to a major supermarket chain. It has two sites: the bakery and its head...
Study smarter with the SolutionInn App