#P16893. [GKS 2022 #G] Walktober

[GKS 2022 #G] Walktober

Problem Description

John participates in an annual walking competition called Walktober. The competition runs for a total of NN days and tracks the daily steps of the participants for all the NN days. Each participant will be assigned a unique ID ranging from 11 to MM where MM 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 NN 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 Format

The first line of the input gives the number of test cases, TT. TT test cases follow.

The first line of each test case contains 33 integers MM, NN, and PP denoting the total number of participants, the total number of days the competition runs, and the last year participant ID of John.

The next MM lines describe the scoreboard of the previous year and contains NN integers each.

The jj-th integer of the ii-th line denotes the step count Si,jS_{i,j} of the participant with ID ii on the jj-th day of the competition.

Output Format

For each test case, output one line containing Case #xx: yy, where xx is the test case number (starting from 11) and yy is the minimum total additional steps needed by John to achieve his goal.

1
2 3 1
1000 2000 3000
1500 1500 3000
Case #1: 500
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

Hint

In the Sample Case, the competition ran for 33 days and the participant ID of John was 11. On day 11, as the other participant has more steps, John needs 500500 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 500500 additional steps to achieve his goal.

In the Additional Sample Case #1\#1, the competition ran for 22 days and the participant ID of John was 33. He needs an additional 10001000 steps on day 11 and 00 steps on day 22 to achieve his goal. So, he needs a total of 10001000 additional steps to achieve his goal.

In the Additional Sample Case #2\#2, the competition ran for 33 days and the participant ID of John was 22. He needs an additional 00 steps on day 11, 20002000 steps on day 22, and 500500 steps on day 33 to achieve his goal. So, he needs a total of 25002500 additional steps to achieve his goal.

Limits

1T1001 \le T \le 100.

1N311 \le N \le 31.

1Si,j600001 \le S_{i,j} \le 60000 for all ii and jj.

1PM1 \le P \le M.

Test Set 11

M=2M = 2.

Test Set 22

2M10002 \le M \le 1000.