#K95512. Minimum Trip Cost

    ID: 38880 Type: Default 1000ms 256MiB

Minimum Trip Cost

Minimum Trip Cost

You are given n clusters. Each cluster contains one or more cost values, each representing the expense to visit a spot in that cluster. Your task is to choose exactly one spot from each cluster so that the total cost is minimized.

Formally, let \( C_i \) be the set of costs in the \( i^{th} \) cluster for \( 1 \leq i \leq n \). You need to compute the value:

[ \text{Total Cost} = \sum_{i=1}^n \min(C_i) ]

Output the minimum total cost.

inputFormat

The input is read from stdin and has the following format:

  1. The first line contains a single integer \( n \) representing the number of clusters.
  2. Each of the next \( n \) lines contains space-separated integers. Each line represents the cost values for a cluster.

outputFormat

Output a single integer to stdout: the minimum total cost computed as the sum of the minimum cost from each cluster.

## sample
3
10 50 70
20 40
5 20 40 10
35