You can only take 10% margin from the total sales. It’s a painful restriction but you bought a…
You can only take 10% margin from the total sales. It’s a painful restriction but you bought a magical stone from a wandering magician that tells you the budget of a customer who visits your store. Using that magical information, you can sell the most expensive and affordable product to all customers. You need to implement a program that calculates the maximum profit from your inventory list and all the visiting customers’ budget. The customers will always buy your first recommendation due to the magical force of the stone, only if your recommendation is affordable to their budget.
Unfortunately, your inventory list is all messed up and it will take too long to search the right item for each one of the customers. Implementation Instructions All prices and budgets will be given as a positive integer line by line, and -1 will note the end of each. You need to print out the maximum profit (max. total sales divided by 10). There will be some relatively large input and an execution time limit. Therefore, you need to utilize the binary search. You cannot sell item again that has been already sold. And assume that you can sell only one product to each customer. If there is no item affordable to the customer, (due to the small budget) you cannot sell any of your product to those.
Specification 1. The program is going to receive a sequence of prices of the items. You need the price list sorted to get full points.
2. After that, the program is going to receive a sequence of budgets of the customers line by line. You need to sell the most expensive product possible to each customer’s budget. You need to use the same technique from above to efficiently find the appropriate product.
3. Print out the maximum profit. (Max. total sales divided by 10)