#613
Silver III
Air Cownditioning II
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

With the hottest recorded summer ever at Farmer John's farm, he needs a way to cool down his cows. Thus, he decides to invest in some air conditioners.

Farmer John's NN cows (1N201 \leq N \leq 20) live in a barn that contains a sequence of stalls in a row, numbered 11001 \ldots 100. Cow ii occupies a range of these stalls, starting from stall sis_i and ending with stall tit_i. The ranges of stalls occupied by different cows are all disjoint from each-other. Cows have different cooling requirements. Cow ii must be cooled by an amount cic_i, meaning every stall occupied by cow ii must have its temperature reduced by at least cic_i units.

The barn contains MM air conditioners, labeled 1M1 \ldots M (1M101 \leq M \leq 10). The iith air conditioner costs mim_i units of money to operate (1mi10001 \leq m_i \leq 1000) and cools the range of stalls starting from stall aia_i and ending with stall bib_i. If running, the iith air conditioner reduces the temperature of all the stalls in this range by pip_i (1pi1061 \leq p_i \leq 10^6). Ranges of stalls covered by air conditioners may potentially overlap.

Running a farm is no easy business, so FJ has a tight budget. Please determine the minimum amount of money he needs to spend to keep all of his cows comfortable. It is guaranteed that if FJ uses all of his conditioners, then all cows will be comfortable.

입력

The first line of input contains NN and MM.

The next NN lines describe cows. The iith of these lines contains sis_i, tit_i, and cic_i.

The next MM lines describe air conditioners. The iith of these lines contains aia_i, bib_i, pip_i, and mim_i.

For every input other than the sample, you can assume that M=10M = 10.

출력

Output a single integer telling the minimum amount of money FJ needs to spend to operate enough air conditioners to satisfy all his cows (with the conditions listed above).

예제 입력 1

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

예제 출력 1

10
코드 제출

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

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