#C3378. Aggregate Daily Sales Across Stores
Aggregate Daily Sales Across Stores
Aggregate Daily Sales Across Stores
You are given the daily sales data of several stores. Each store provides its sales data for a sequence of days. The sales data is stored in a matrix where each row represents a store and each column represents a day.
Your task is to compute the total sales for each day across all stores. In other words, you need to sum the sales figures for each corresponding day from every store.
Input Format: The first line contains two integers n and m where n is the number of stores and m is the number of days. This is followed by n lines, each containing m integers separated by spaces representing the sales data for a store.
Output Format: Output a single line with m integers separated by spaces. Each integer represents the total sales for that day calculated by summing the corresponding sales from all the stores.
Formula: If we denote the sales matrix as \( A \) with \( A_{i,j} \) representing the sales of the \( i^{th} \) store on the \( j^{th} \) day, the aggregated sales for day \( j \) is given by:
[ S_j = \sum_{i=1}^{n} A_{i,j} ]
Ensure that your solution reads input from stdin
and writes output to stdout
.
inputFormat
The input begins with a line containing two space-separated integers n and m (the number of stores and days, respectively). The next n lines each contain m space-separated integers representing the daily sales figures for a store.
outputFormat
Print a single line containing m space-separated integers. Each integer is the summed sales for each day across all stores.
## sample3 3
10 20 30
5 15 25
7 14 21
22 49 76