Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Wood Cutting Yraglac recently decided to get into the wood cutting business, and now has N customers who would like to have their wood cut.
Wood Cutting
Yraglac recently decided to get into the wood cutting business, and now has
customers who would like to have their wood cut. A piece of wood of size takes
time units to cut, and Yraglac can only cut a single piece of wood at a time. To
maximize customer happiness, Yraglac would like to minimize the average
total time a customer has to wait to have all of their wood pieces cut. Can you
help him?
Input
The first line contains a single integer giving the number of test cases.
Each test case begins with an integer the number of
customers. lines follow, where the th line begins with an integer
the number of wood pieces that customer i would like to have
cut, followed by integers, the sizes of the wood pieces of the customer. Each
wood piece has a size between and inclusive. The total number of wood
pieces will not exceed
Output
For each test case, output a single line containing the minimum average total
time a customer will wait to have all of their wood pieces cut. Your answer will
be considered correct if its absolute or relative error doesn't exceed
Sample Input
Sample Output
a Implement a greedy algorithm using your preferred language and submit your implementation via Kattis. Submit a screenshot of your submission that clearly shows your code.
b Prove that your algorithm is correct by proving the greedy choice and optimal substructure properties.
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