Answered step by step
Verified Expert Solution
Question
1 Approved Answer
code javascript: Given a set of orders, calculate how many of them can be fulfilled. Task description A technology company announced that a new supply
code javascript: Given a set of orders, calculate how many of them can be fulfilled.
Task description
A technology company announced that a new supply of P monitors would soon be available at their store. There were N orders numbered from to N placed by customers who wanted to buy those monitors. The Kth order has to be delivered to a location at distance DK from the store and is for exactly CK monitors.
Now the time has come for the monitors to be delivered. The orders will be fulfilled one by one. To minimize the shipping time, it has been decided that the deliveries will be made in order of increasing distance from the store. If there are many customers at the same distance, they can be processed in any order. Monitors to more distant customers will be delivered only once all orders to customers closer to the store have already been fulfilled.
What is the maximum total number of orders that can be fulfilled?
Write a function:
function solutionD C P;
that, given two arrays of integers D and C and an integer P returns the maximum total number of orders that can be fulfilled.
Examples:
Given D C and P the function should return The customers at distances and will have their orders fulfilled and monitors will be delivered.
Given D C and P the function should return Only the order for the customer at distance will be fulfilled. There will not be enough monitors in the store for the customer at distance Therefore, orders for customers at distances and will not be fulfilled.
Given D C and P the function should return
Given D C and P the function should return
Write an efficient algorithm for the following assumptions:
N is an integer within the range ;
each element of arrays D and C is an integer within the range ;
P is an integer within the range
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started