Walktober Solution (4pts, 6pts)
Problem
John participates in an annual walking competition called Walktober. The competition runs for a total of days and tracks the daily steps of the participants for all the days. Each participant will be assigned a unique ID ranging from to where is the total number of registered participants. A global scoreboard is maintained tracking the daily steps of each participant.
John is determined to win Walktober this year and his goal is to score the maximum daily steps on each of the days among all the participants. Having participated in Walktober last year as well, he wanted to know how many steps he fell short of in achieving his goal. Given the previous year scoreboard, calculate the minimum additional steps he needed over his last year score in order to achieve his goal of scoring the maximum daily steps every day.
Input
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case contains three integers , , and denoting the total number of participants, the total number of days the competition runs, and the last year participant ID of John.
The next lines describe the scoreboard of the previous year and contains integers each. The -th integer of the -th line denotes the step count of the participant with ID on the -th day of the competition.
Output
For each test case, output one line containing Case #:
, where is the test case number (starting from 1) and is the minimum total additional steps needed by John to achieve his goal.
Limits
Memory limit: 1 GB.
.
.
for all and .
.
Test Set 1
Time limit: 20 seconds.
.
Test Set 2
Time limit: 40 seconds.
.
Sample
Note: there are additional samples that are not run on submissions down below.1 2 3 1 1000 2000 3000 1500 1500 3000
Case #1: 500
In the Sample Case, the competition ran for days and the participant ID of John was . On day , as the other participant has more steps, John needs additional steps. On the rest of the days, as John already has the maximum steps, he needs no additional steps. So, he needs a total of additional steps to achieve his goal.
Additional Sample - Test Set 2
The following additional sample fits the limits of Test Set 2. It will not be run against your submitted solutions.2 3 2 3 1000 2000 1500 4000 500 4000 3 3 2 1000 2000 1000 1500 2000 1000 500 4000 1500
Case #1: 1000 Case #2: 2500
In the Sample Case #1, the competition ran for days and the participant ID of John was . He needs an additional steps on day and steps on day to achieve his goal. So, he needs a total of additional steps to achieve his goal.
In the Sample Case #2, the competition ran for days and the participant ID of John was . He needs an additional steps on day , steps on day , and steps on day to achieve his goal. So, he needs a total of additional steps to achieve his goal.
0 Comments
If you have any doubts/suggestion/any query or want to improve this article, you can comment down below and let me know. Will reply to you soon.