#K78397. Employee Performance Score Update
Employee Performance Score Update
Employee Performance Score Update
You are given n employees with an initial performance score of 0. Then, you will process q events sequentially. There are two types of events:
- Type 1: [1, id, x] — Increase the performance score of employee with id id by x.
- Type 2: [2, x] — For every employee, if their performance score is greater than x, adjust it according to \[ \text{score}^\prime = \min(\text{score},\,x)\]
After processing all events, output the final performance scores of all employees in the order from employee 1 to employee n.
Example:
Input: 5 4 1 3 20 1 2 5 2 10 1 4 7</p>Output: 0 5 10 7 0
inputFormat
The first line contains two integers n and q, representing the number of employees and the number of events, respectively.
The following q lines each describe an event. Each event is given in one of the following forms:
- For a type 1 event:
1 id x
, meaning that employee with id id will have x added to their current performance score. - For a type 2 event:
2 x
, meaning that every performance score greater than x will be set to x (i.e., updated as \(\min(\text{score}, x)\)).
outputFormat
Output a single line containing n integers separated by spaces, representing the final performance scores of employees from id 1 to n.
## sample5 4
1 3 20
1 2 5
2 10
1 4 7
0 5 10 7 0