#C9924. Minimum Sum of Sequences
Minimum Sum of Sequences
Minimum Sum of Sequences
You are given N sequences of positive integers. For each sequence, you must select exactly one integer. Your goal is to minimize the total sum of the selected integers. In other words, from each sequence, you must choose the smallest integer, and then output the sum of these minima.
The problem can be formalized as follows: given sequences \(S_1, S_2, \dots, S_N\), you need to compute \[ \text{result} = \sum_{i=1}^{N} \min(S_i), \] where \(\min(S_i)\) denotes the smallest element in the sequence \(S_i\).
Example:
Input: 3 1 2 3 4 5 6 7 8 9</p>Output: 12
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer N that represents the number of sequences.
- Each of the following N lines contains a sequence of space-separated positive integers.
outputFormat
Output to standard output (stdout) a single integer which is the minimum possible sum calculated by selecting the smallest integer from each sequence.
## sample3
1 2 3
4 5 6
7 8 9
12