#694
Unrated
Deforestation
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John is expanding his farm! He has identified the perfect location in the Red-Black Forest, which consists of NN trees (1N1051 \le N \le 10^5) on a number line, with the ii-th tree at position xix_i (109xi109-10^9 \le x_i \le 10^9).

Environmental protection laws restrict which trees Farmer John can cut down to make space for his farm. There are KK restrictions (1K1051 \leq K \leq 10^5) specifying that there must always be at least tit_i trees (1tiN1 \leq t_i \leq N) in the line segment [li,ri][l_i, r_i], including the endpoints (109liri109-10^9 \le l_i \leq r_i \le 10^9). It is guaranteed that the Red-Black Forest initially satisfies these restrictions.

Farmer John wants to make his farm as big as possible. Please help him compute the maximum number of trees he can cut down while still satisfying all the restrictions!

입력

Each input consists of TT (1T101 \le T \le 10) independent test cases. It is guaranteed that the sums of all NN and of all KK within an input each do not exceed 31053 \cdot 10^5.

The first line of input contains TT. Each test case is then formatted as follows:

The first line contains integers NN and KK.The next line contains the NN integers x1,,xNx_1, \dots, x_N.Each of the next KK lines contains three space-separated integers: lil_i, rir_i and tit_i.

출력

For each test case, output a single line with an integer denoting the maximum number of trees Farmer John can cut down.

예제 입력 1

3
7 1
8 4 10 1 2 6 7
2 9 3
7 2
8 4 10 1 2 6 7
2 9 3
1 10 1
7 2
8 4 10 1 2 6 7
2 9 3
1 10 4

예제 출력 1

4
4
3

점수

Input 2: N,K16N, K \le 16Inputs 3-5: N,K1000N, K \le 1000Inputs 6-7: ti=1t_i = 1 for all i=1,,Ki = 1, \dots, K.Inputs 8-11: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.