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

25762번 - Easy Problem 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB51125.000%

문제

Askhat is a prospective businessman. He quickly figured that programming is an unprofitable business, so he decided to open a chicken farm.

His farm consists of $n$ chickens ordered in a row. The $i$-th chicken can eat at most $a_i$ grains. There are $m$ feeders, each described by integers $l_j,ドル $r_j,ドル $c_j$. The $j$-th feeder can feed the $i$-th chicken if $l_j \le i \le r_j,ドル and there are $c_j$ grains in this feeder.

Turns out that every business has its own pitfalls, in this case it has the face of chicken feeding control, represented by Ildar. He claims that every respectable chicken farm must have a chicken representative. That is, there must exist a chicken $i$ such that $l_j \le i \le r_j$ holds for every feeder $j$. All feeders that don't obey this rule must be exterminated.

Now Askhat asks you to find, for each $i,ドル what is the maximum number of grains that can be fed to chickens if we leave only feeders that can feed chicken $i$.

입력

The first line contains a single integer $t$ (1ドル \leq t \leq 10^4$) --- the number of test cases. Description of test cases follows.

The first line of each test case contains two integers $n,ドル $m$ (1ドル \le n, m \le 10^5$) --- the number of chickens and the number of feeders respectively.

The next line contains $n$ integers $a_1, a_2, \ldots, a_n$ (0ドル \le a_i \le 10^9$) --- the number of grains that chickens can eat.

Each of the next $m$ lines contains three integers $l_j,ドル $r_j,ドル $c_j$ (1ドル \le l_j \le r_j \le n,ドル 0ドル \le c_j \le 10^9$) --- description of the $j$-th feeder.

It is guaranteed that both the sum of $n$ and the sum of $m$ for all test cases do not exceed 10ドル^5$.

출력

For each test case, print $n$ integers --- the answer to the problem.

제한

예제 입력 1

1
4 3
3 3 2 2
1 2 2
3 3 3
2 2 4

예제 출력 1

2 5 2 0

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 7: HSE Koresha Contest A번

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

출처

대학교 대회

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

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