#K35992. Adjusting Building Temperatures
Adjusting Building Temperatures
Adjusting Building Temperatures
You are given n buildings, each with an initial temperature of 0. You are also given m commands. Each command consists of three integers: i, t, and d. Here, i represents the 1-indexed building ID, t is the time at which the command is issued (this value is irrelevant for the final result), and d is the temperature difference to be applied to the building.
Your task is to process all the commands and compute the final temperature of each building. The final temperature of the i-th building is the sum of all temperature differences applied to it.
Solve the problem by reading input from stdin
and writing the output to stdout
.
inputFormat
The first line of input contains two integers n
and m
: the number of buildings and the number of commands, respectively. Each of the following m
lines contains three space-separated integers: i
, t
, and d
, describing a command. Note that although t
is provided, it is not used in the computation.
outputFormat
Output a single line consisting of n
integers separated by a single space. These integers represent the final temperatures of the buildings from 1 through n after all commands have been executed.## sample
3 5
1 1 5
2 2 -3
3 3 10
1 4 -2
3 3 -5
3 -3 5