Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ONLY JAVA CODE Background For this lab please demonstrate your understanding of arrays in your solution. An important operation that is associated with arrays is
ONLY JAVA CODE
Background For this lab please demonstrate your understanding of arrays in your solution. An important operation that is associated with arrays is sorting. We can sort an array in Java using the sort method in the Arrays class. By default it sorts in ascending order. The Task Professor Smith needs new research equipment to further his research to save the manatees in the Indian Lagoon River. The money made from the trading shares of Volatity Inc. will be used to purchase lab equipment. Currently the store is having a sale in which one can buy three items, but pay for only two items. The professor cannot pass up such a good deal. However, the store that sells the lab equipment makes you pay for the most expensive items. For an example, when Professor Smith checks out with seven items, costing 400, 350, 300, 250, 200, 150, and 100 dollars, the total will be 1500 dollars. In this case the savings is 450 dollars. You realize that in the case there is a stragety that saves more money by going to the checkout counter multiple times. For example, if the professor first takes items that cost 400 , 300 and 250 , the savings will 250 dollars. If the professor then brings the item that costs 150 there is not discout. But if the professor then brings the last items that costs 350,200 and 100 , there is an additional savings of 100 dollars. This all adds up to a total savings of 450 dollars. Your job is to find the maximum discount Professor Smith can get Input The first line of input gives the number of items Professor Smith is buying, 1n200000. The next line gives the prices of these items, which are integers 1pi200000. Sample Input and Output Input 6 400100200350300250 Output 400 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