In Java8 please 3. Maximum Order Volume During the day, a supermarket will receive calls from customers
Fantastic news! We've Found the answer you've been seeking!
Question:
In Java8 please
Transcribed Image Text:
3. Maximum Order Volume During the day, a supermarket will receive calls from customers who want to place orders. The supermarket manager knows in advance the number of calls that will be attempted, the start time, duration and order volume for each call. Only one call can be in progress at any one time, and if a call is not answered, the caller will not call back. The manager must choose which calls to service in order to maximize order volume. Determine that maximum order volume. Example start = [10, 5, 15, 18, 30] duration = [30, 12, 20, 35, 35] volume = [50, 51, 20, 25, 10] Solve question 2 The above data as a table: Caller 1 2 3 4 5 Start time 10 5 15 18 30 Duration 30 12 20 35 35 The first call will start at time = 10, and last until time = 40. The second call will start at time = 5, and last until time = 17. The third call will start at time = 15, and last until time = 35. The fourth call will start at time = 18, and last until time = 53. The fifth call will start at time = 30, and last until time = 65. Order volume 50 51 20 25 10 The first call completely overlaps the second and third calls, and partially overlaps the fourth and fifth calls. Choosing calls that do not overlap, answering the 2nd and 4th calls will lead to the maximum total order volume of 51 + 25 = 76. Function Description Function Description Complete the function phoneCalls in the editor below. phoneCalls has the following parameter(s): int start[n]: the start times of each call int duration[n]: the durations of each call int volume[n]: the volumes of each order Returns int: the maximum possible volume of orders that can be received Constraints 1≤n≤105 ≤ startli) ≤ 109 Solve question 2 1- duration[i] ≤ 10⁹ • 1 ≤ volume[i] ≤ 10³ Input Format For Custom Testing The first line contains an integer, n, the size of the start array. Each line i of the n subsequent lines (where 0 Sample Case 0 Sample Input For Custom Testing STDIN Function 3 1 N N WANT 2 4 3 2 WNT Modify submission of question 1, h = 3 1 → volume[] = [1, 2, 3 ] 2 → start[] size n = 3 → start[] = [1, 2, 4 ] 3 → duration [] size n = 3 → duration[] = [ 2, 2, 1 ] Sample Output Explanation The calls happen in the intervals [1,3] [2,4] [4,5] The first and third calls together make up the order volume 4, and their intervals do not intersect. The first and second calls intersect, as do the second and third calls. Only one call from either of these pairs can be serviced. The most efficient calls to answer are the first and third with a total volume of 4. > Sample Case 1 Sample Input For Custom Testing STDIN Function 3 1 10 100 3 1 10 100 - 3 1 10 100 ----- → start [] size n = 3 → start[] = [1, 10, 100 ] → duration [] size n = 3 → duration[] = [1, 10, 100 ] → volume [] size n = 3 → volume[] = [ 1, 10, 100 ] Sample Output 111 Explanation The calls happen in the following intervals - [1 2] [10 20] [100 200] All three calls can be attended. So total volume is 1 + 10 + 100 = 111. Language Java 8 1 > import java.io.*; 14 15 class Result { 16 17 99872~*~¤¶¯M & H M M G 18 19 20 21 22 23 24 25 26 30 31 32 33 34 35 37 38 39 40 41 42 43 ? 4 45 46 7 48 49 50 1 52 53 44 47 } 36 public class Solution { 51 } * Complete the phone Calls function below. * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER_ARRAY start * ★ */ V Autocomplete Ready Ⓒ 2. INTEGER_ARRAY duration 3. INTEGER_ARRAY volume public static int phoneCalls (List start, List duration, List volume) { // Write your code here public static void main(String[] args) throws IOException { BufferedReader buffered Reader = new Buffered Reader (new InputStreamReader (System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter (System.getenv ( OUTPUT_PATH ))); int startCount = Integer.parseInt(bufferedReader.readLine().trim()); List start = IntStream.range (0, startCount).mapToobj (i -> { try { }) return buffered Reader.readLine().replaceAll( \\s+$ , ); } catch (IOException ex) { } throw new RuntimeException (ex); .map (String::trim) .map (Integer::parseInt) .collect(toList()); -0- ? ⠀ Line: 30 Col: 9 3. Maximum Order Volume During the day, a supermarket will receive calls from customers who want to place orders. The supermarket manager knows in advance the number of calls that will be attempted, the start time, duration and order volume for each call. Only one call can be in progress at any one time, and if a call is not answered, the caller will not call back. The manager must choose which calls to service in order to maximize order volume. Determine that maximum order volume. Example start = [10, 5, 15, 18, 30] duration = [30, 12, 20, 35, 35] volume = [50, 51, 20, 25, 10] Solve question 2 The above data as a table: Caller 1 2 3 4 5 Start time 10 5 15 18 30 Duration 30 12 20 35 35 The first call will start at time = 10, and last until time = 40. The second call will start at time = 5, and last until time = 17. The third call will start at time = 15, and last until time = 35. The fourth call will start at time = 18, and last until time = 53. The fifth call will start at time = 30, and last until time = 65. Order volume 50 51 20 25 10 The first call completely overlaps the second and third calls, and partially overlaps the fourth and fifth calls. Choosing calls that do not overlap, answering the 2nd and 4th calls will lead to the maximum total order volume of 51 + 25 = 76. Function Description Function Description Complete the function phoneCalls in the editor below. phoneCalls has the following parameter(s): int start[n]: the start times of each call int duration[n]: the durations of each call int volume[n]: the volumes of each order Returns int: the maximum possible volume of orders that can be received Constraints 1≤n≤105 ≤ startli) ≤ 109 Solve question 2 1- duration[i] ≤ 10⁹ • 1 ≤ volume[i] ≤ 10³ Input Format For Custom Testing The first line contains an integer, n, the size of the start array. Each line i of the n subsequent lines (where 0 Sample Case 0 Sample Input For Custom Testing STDIN Function 3 1 N N WANT 2 4 3 2 WNT Modify submission of question 1, h = 3 1 → volume[] = [1, 2, 3 ] 2 → start[] size n = 3 → start[] = [1, 2, 4 ] 3 → duration [] size n = 3 → duration[] = [ 2, 2, 1 ] Sample Output Explanation The calls happen in the intervals [1,3] [2,4] [4,5] The first and third calls together make up the order volume 4, and their intervals do not intersect. The first and second calls intersect, as do the second and third calls. Only one call from either of these pairs can be serviced. The most efficient calls to answer are the first and third with a total volume of 4. > Sample Case 1 Sample Input For Custom Testing STDIN Function 3 1 10 100 3 1 10 100 - 3 1 10 100 ----- → start [] size n = 3 → start[] = [1, 10, 100 ] → duration [] size n = 3 → duration[] = [1, 10, 100 ] → volume [] size n = 3 → volume[] = [ 1, 10, 100 ] Sample Output 111 Explanation The calls happen in the following intervals - [1 2] [10 20] [100 200] All three calls can be attended. So total volume is 1 + 10 + 100 = 111. Language Java 8 1 > import java.io.*; 14 15 class Result { 16 17 99872~*~¤¶¯M & H M M G 18 19 20 21 22 23 24 25 26 30 31 32 33 34 35 37 38 39 40 41 42 43 ? 4 45 46 7 48 49 50 1 52 53 44 47 } 36 public class Solution { 51 } * Complete the phone Calls function below. * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER_ARRAY start * ★ */ V Autocomplete Ready Ⓒ 2. INTEGER_ARRAY duration 3. INTEGER_ARRAY volume public static int phoneCalls (List start, List duration, List volume) { // Write your code here public static void main(String[] args) throws IOException { BufferedReader buffered Reader = new Buffered Reader (new InputStreamReader (System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter (System.getenv ( OUTPUT_PATH ))); int startCount = Integer.parseInt(bufferedReader.readLine().trim()); List start = IntStream.range (0, startCount).mapToobj (i -> { try { }) return buffered Reader.readLine().replaceAll( \\s+$ , ); } catch (IOException ex) { } throw new RuntimeException (ex); .map (String::trim) .map (Integer::parseInt) .collect(toList()); -0- ? ⠀ Line: 30 Col: 9
Expert Answer:
Answer rating: 100% (QA)
import javautil public class Solution public static int phoneCallsList start List duration List volu... View the full answer
Related Book For
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier
Posted Date:
Students also viewed these electrical engineering questions
-
please show me er diagram as well as explain it between room and customer there will be many to many cardinality ratio please convert it into one to many .also show the entity hotel have staff and...
-
Please explain the effects of Disciplined Imagination. Please explain the unseen social and ethical implications in Disciplined Imagination.
-
Please comment on the use of social media in selection Please use outside source to comment on as many aspects legal ethical what a company needs to be aware of privacy etc
-
Use any method to evaluate the limit or show that it does not exist. lim (x,y) (0,0) x - y x + y
-
Barry Galvin is executive vice president of Community Bank. Active in community affairs, Galvin serves on the board of directors of The Salvation Army. The Salvation Army is expanding rapidly and is...
-
Apply nodal analysis to find i o and the power dissipated in each resistor in the circuit of Fig. 3.64 . 12.5 A 50 V Vo 100 V (+
-
The summary statistics for a certain set of points are: n = 20, se = 4.65, (x x)2 = 118.26, and b1 = 1.62. Assume the conditions of the linear model hold. A 99% confidence interval for 1 will be...
-
The International Accounting Standards Committee (IASC) was formed in 1973. In 2001 the IASC was replaced by the International Accounting Standards Board (IASB). Required: a. What was the purpose of...
-
Understand the concept of the time value of money. Understand the difference between an annuity and a single sum. Know how to affect the compounding periods and interest rate if an investment...
-
Evaluate the function \(f(x, y)=\frac{2}{3} e^{-x / 2} \cos (y-1)\) for \(x=-0.23, y=2.7\) by: a. Using the subs command. b. Conversion into a MATLAB function.
-
How do epigenetic modifications, such as DNA methylation and histone acetylation, regulate gene expression patterns in multicellular organisms, and what are the implications for development,...
-
A short cantilevered round peg is 48 mm in diameter and extends 12 mm from the wall. It is loaded, as shown, with a force F-52 kN appiled at the tip in the negative z direction, and a torque T-800...
-
Watch the Ted Talk linked below and answer the following questions. https://www.ted.com/talks/richard_wilkinson_how_economic_inequality_harms_societies?language=enLinks to an external site. What is...
-
The following information is available for completed Job No. 402: direct materials, $120000; direct labor, $235000; manufacturing overhead applied, $125000; units produced, 5000 units; units sold,...
-
The following information concerns Transformation Inc.'s equivalent units in September: Units Beginning work in process (50% complete) 2,000 Units started during June 8,000 Units completed and...
-
For Michelle, one of the most exciting aspects of landing a full-time job was being able to buy a different car! Even though she will be working in an urban area, she will need a reliable vehicle to...
-
St. Cloud Mattress Company is considering a capital renovation of their current, downtrodden facility. One of the criteria St. Cloud uses to evaluate this renovation is by calculating the net cash...
-
Suppose that a flow network G = (V, E) violates the assumption that the network contains a path s t for all vertices V. Let u be a vertex for which there is no path s u t. Show that there must...
-
Consider the following decision tree, where the probabilities for each event node are shown in parentheses. The dollar amount given next to each branch is the cash flow generated along that branch,...
-
Because of your knowledge of management science, your boss has asked you to analyze a product mix problem involving two products and two resources. The model is shown below in algebraic form, where...
-
Ken and Larry, Inc., supplies its ice cream parlors with three flavors of ice cream: chocolate, vanilla, and banana. Due to extremely hot weather and a high demand for its products, the company has...
-
Which of the following statements regarding the audit of negotiable notes receivable is not correct? a. Confirmation from the debtor is an acceptable alternative to inspection. b. Physical inspection...
-
To conceal defalcations involving receivables, the auditor would expect an experienced bookkeeper to charge which of the following accounts? a. Sales returns. b. Miscellaneous income. c. Petty cash....
-
An auditor's risk of misstatement of accounts receivable is least likely to increase if there is a. An increase in customer complaints about their accounts. b. A general slowdown in cash collections....
Study smarter with the SolutionInn App