#C1838. Trip Expenditure

    ID: 45087 Type: Default 1000ms 256MiB

Trip Expenditure

Trip Expenditure

During a group trip, you are given the number of friends \(N\) and the number of days \(M\), along with a matrix representing the daily expenditures for each friend. For each day \(j\) (\(1 \leq j \leq M\)), you are to compute:

  • \(T_j = \sum_{i=1}^{N} a_{ij}\): the total amount spent on day \(j\).
  • \(m_j = \min_{1 \leq i \leq N} a_{ij}\): the minimum expenditure among the friends for day \(j\).

Additionally, compute the overall total expenditure for the entire trip \(T = \sum_{j=1}^{M} T_j\).

Your task is to read the input, calculate these values, and print the results as described below.

inputFormat

The first line contains two integers \(N\) and \(M\) separated by a space, representing the number of friends and the number of days, respectively.

This is followed by \(N\) lines, each containing \(M\) integers. The \(i\)-th line represents the daily expenditures of the \(i\)-th friend, with each integer separated by a space.

outputFormat

Print the results in three lines:

  1. The first line contains \(M\) integers representing the total expenditure for each day, separated by spaces.
  2. The second line contains \(M\) integers representing the minimum expenditure among the friends for each day, separated by spaces.
  3. The third line contains a single integer which is the overall total expenditure for the trip.
## sample
3 4
200 150 100 50
50 60 70 80
100 200 150 50
350 410 320 180

50 60 70 50 1260

</p>