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

문제

Farmer John has MM cows, conveniently labeled 1M1 \ldots M, who enjoy the occasional change of pace from eating grass. As a treat for the cows, Farmer John has baked NN pies (1N3001 \leq N \leq 300), labeled 1N1 \ldots N. Cow ii enjoys pies with labels in the range [li,ri][l_i, r_i] (from lil_i to rir_i inclusive), and no two cows enjoy the exact same range of pies. Cow ii also has a weight, wiw_i, which is an integer in the range 11061 \ldots 10^6.

Farmer John may choose a sequence of cows c1,c2,,cK,c_1,c_2,\ldots, c_K, after which the selected cows will take turns eating in that order. Unfortunately, the cows don't know how to share! When it is cow cic_i's turn to eat, she will consume all of the pies that she enjoys --- that is, all remaining pies in the interval [lci,rci][l_{c_i},r_{c_i}]. Farmer John would like to avoid the awkward situation occurring when it is a cows turn to eat but all of the pies she enjoys have already been consumed. Therefore, he wants you to compute the largest possible total weight (wc1+wc2++wcKw_{c_1}+w_{c_2}+\ldots+w_{c_K}) of a sequence c1,c2,,cKc_1,c_2,\ldots, c_K for which each cow in the sequence eats at least one pie.

SCORING:

Test cases 2-5 satisfy N50N\le 50 and M20M\le 20. Test cases 6-9 satisfy N50.N\le 50.

입력

The first line contains two integers NN and MM (1MN(N+1)2)\left(1\le M\le \frac{N(N+1)}{2}\right).

The next MM lines each describe a cow in terms of the integers wi,liw_i, l_i, and rir_i.

출력

Print the maximum possible total weight of a valid sequence.

예제 입력 1

2 2
100 1 2
100 1 1

예제 출력 1

200
코드 제출

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

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