#C8020. Update Ticket Prices
Update Ticket Prices
Update Ticket Prices
You are given n tickets with initial prices and u update operations. Each update operation is defined by three integers l, r, and p and means that every ticket in the range from index l to r (1-indexed) will have its price changed to p.
The problem can be formulated as follows:
Given integers \( n \) and \( u \), a sequence of ticket prices \( a_1, a_2, \dots, a_n \), and \( u \) updates in the form \( (l_i, r_i, p_i) \), update the ticket prices such that for each update, for all indices \( i \) with \( l_i \le i \le r_i \), the price becomes \( p_i \). Finally, output the updated sequence of ticket prices.
Note: The input is read from the standard input (stdin) and the output should be written to the standard output (stdout).
inputFormat
The first line of input contains two integers \( n \) and \( u \) where \( n \) is the number of tickets and \( u \) is the number of update operations.
The second line contains \( n \) space-separated integers representing the initial ticket prices.
Each of the next \( u \) lines contains three space-separated integers \( l \), \( r \), and \( p \) indicating that the prices of the tickets from index \( l \) to \( r \) (inclusive) must be updated to \( p \).
outputFormat
Output a single line containing \( n \) space-separated integers representing the updated ticket prices.
## sample5 3
100 200 300 400 500
1 3 50
2 4 150
4 5 250
50 150 150 250 250