#K33962. Minimum Days with Skip
Minimum Days with Skip
Minimum Days with Skip
You are given a list of tasks, where each task takes a certain number of days to complete. You have the opportunity to skip exactly one task. Your goal is to minimize the total number of days required to complete the remaining tasks.
Formally, given a list \(A = [a_1, a_2, \dots, a_n]\), compute the value:
\(\text{result} = \begin{cases}\sum_{i=1}^{n} a_i - \max(A) & \text{if } n > 0,\\ 0 & \text{if } n = 0.\end{cases}\)
If there are no tasks (i.e. the list is empty), then the answer is 0.
inputFormat
The input is read from stdin and has the following format:
- The first line contains a single integer \(T\) representing the number of test cases.
- For each test case, the first integer \(n\) indicates the number of tasks, followed by \(n\) integers representing the time required for each task.
Note that if \(n = 0\), there are no tasks for that test case.
outputFormat
For each test case, output a single integer on a new line which represents the minimum days required after skipping the task that takes the longest time.
## sample3
5 1 2 3 4 5
4 1 2 2 1
1 10
10
4
0
</p>