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

19336번 - Mines 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB5413821.053%

문제

There are $N$ mines on the number line. Mine $i$ is at position $p_i$ and has an explosion radius $r_i$. It initially costs $c_i$ to detonate. If mine $i$ is detonated, an explosion occurs on interval $[p_i - r_i, p_i + r_i]$ and all mines in that interval (inclusive of the endpoints) are detonated for free, setting off a chain reaction. You need to process $Q$ operations of the form $(m,c)$: Change the cost of detonating mine $m$ to $c$. Output the minimum cost required to detonate all mines after each change. Note that each change is permanent.

입력

The first line contains integers $N$ and $Q$ (1ドル \leq N, Q \leq 200,000円$). The next $N$ lines contain information on the mines. The $i$-th of these lines contains integers $p_i,ドル $r_i$ and $c_i$ (1ドル \leq p_i,r_i,c_i \leq 10^9$). The next $Q$ lines each contains space separated integers $m$ and $c$ (1ドル \leq m \leq N,ドル 1ドル \leq c \leq 10^9$).

출력

Output $Q$ lines. The $i$-th line should contain the minimum cost required to detonate all mines after the $i$-th operation.

제한

예제 입력 1

4 2
1 1 1
6 3 10
8 2 5
10 2 3
1 1
4 11

예제 출력 1

4
6

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2018 > Day 9: Carnegie Mellon U Contest A번

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

출처

대학교 대회

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

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