Logo
(追記) (追記ここまで)

11853번 - Trading 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 64 MB68353454.839%

문제

There are N small villages close to the highway between Almaty and Taraz numbered from 1 to N. At the beginning of the winter M unknown traders began trading knitted hats in these villages. They have only two rules: never trade in one place more than once (one day) and increase the price on hats each day.

More formally, each i-th trader:

  1. begins trading in village Li with starting price Xi.
  2. each day he moves to the next adjacent village, i.e. if he was trading in village j yesterday, then today he is trading in village j + 1.
  3. each day he increases the price by 1, so if yesterday's price was x, then today's price is x + 1.
  4. stops trading at village Ri (after he traded his knitted hats in village Ri).

The problem is for each village to determine the maximal price that was there during the whole trading history.

입력

Each line contains two integer number N (1 ≤ N ≤ 300000) and M (1 ≤ M ≤ 300000) - number of villages and traders accordingly.

Next M lines contains 3 numbers each: Li, Ri (1 ≤ Li ≤ Ri ≤ N) and Xi (1 ≤ Xi ≤ 109) - numbers of first and last village and starting price for i-th trader.

출력

Output N integer numbers separating them with spaces - i-th number being the maximal price for the trading history of i-th village. If there was no trading in some village, output 0 for it.

제한

예제 입력 1

5 2
1 3 2
2 4 6

예제 출력 1

2 6 7 8 0

예제 입력 2

6 4
4 4 3
1 2 5
5 6 1
6 6 1

예제 출력 2

5 6 0 3 1 2

힌트

출처

Olympiad > International Zhautykov Olympiad > IZhO 2013 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /