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

22045번 - Chicken Farm 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB6000.000%

문제

Askhat is a young businessman. He realized that programming is not a very profitable business. Therefore, he decided to start a chicken farm.

On his farm, there are $n$ chickens that stand in a row. The $i$-th chicken can eat no more than $a_i$ grains. There are $m$ feeders, each one is described by the numbers $l_j,ドル $r_j$ and $c_j$. Chicken $i$ can eat from feeder $j,ドル if $l_j \le i \le r_j,ドル and all chickens in total can eat no more than $c_j$ grains from the $j$-th feeder.

As in any business, problems arise from nowhere. This time the government inspector came to his farm. He said that by current regulations, there should be at least two chickens that can eat from all feeders. In other words, there should be an integer $i$ such that 1ドル \le i \le n - 1,ドル and for all feeders $l_j \le i$ and $i + 1 \le r_j$. All feeders that don’t satisfy this property will be destroyed. Askhat asks you to find for each $i$ what the maximum number of grains can be fed to chickens if you leave only feeders, from which chickens $i$ and $i + 1$ can eat.

입력

The first line contains a single integer $t$ — the number of tests in the input (1ドル \le t \le 2,000円$).

The following lines describe the given tests. The first line of each test contains two integers $n$ and $m$ — the number of chickens and the number of feeders, respectively (1ドル \le n \le 2,000円,ドル 1ドル \le m \le 100,000円$). The following line contains $n$ integers $a_i$ — the maximum number of grains that the $i$-th chicken can eat (0ドル \le a_i \le 10^9$). The following $m$ lines contain three integers each $l_j,ドル $r_j,ドル and $c_j$ describing the $j$-th feeder (1ドル \le l_j \le r_j \le n,ドル 0ドル \le c_j \le 10^9$).

The total sum of all $n$ in the input doesn’t exceed 2ドル,000円$.

The total sum of all $m$ in the input doesn’t exceed 100ドル,000円$.

The total sum of all $n \cdot m$ in the input doesn’t exceed 10ドル^7$.

출력

For each test print $n-1$ integers: the $i$-th of these integers should equal to the maximum number of grains that can be fed to chickens if you leave only feeders with $l_j \le i$ and $r_j \ge i + 1$.

제한

서브태스크

번호배점제한
15

$\sum{n} \le 100,ドル $\sum{m} \le 100$

210

$\sum{n} \le 500,ドル $\sum{m} \le 500$

325

$\sum{n} \le 1,000円,ドル $\sum{m} \le 1,000円$

410

$\sum{n} \le 2,000円,ドル $\sum{m} \le 100,000円,ドル $l_i \le l_{i+1},ドル $r_i \le r_{i+1}$

520

$\sum{n} \le 500,ドル $\sum{m} \le 100,000円$

630

$\sum{n} \le 2,000円,ドル $\sum{m} \le 100,000円$

예제 입력 1

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

예제 출력 1

4 4 9 4

힌트

If you leave the feeders, from which chickens 1ドル$ and 2ドル$ can eat, then only the first feeder will remain. In this case, you can feed the first chicken all the grains from it, and four grains will be fed.

Similarly, if you leave the feeders, from which the second and third chickens can eat.

If you leave the feeders, from which chickens 3ドル$ and 4ドル$ can eat, then all the feeders will remain. Then you can feed the first chicken grains from the first feeder, and the third and fourth chickens grains from the remaining feeders. Thus, nine grains will be fed.

In the last case, you leave the feeders, from which chickens 4ドル$ and 5ドル$ can eat. Only the second feeder will remain. You can feed all grains from it.

출처

Contest > Innopolis Open in Informatics > Innopolis Open 2019-2020 Finals E번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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