Movatterモバイル変換


[0]ホーム

URL:


Logo

33346번 -Segments Removal다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초2048 MB0000.000%

문제

Consider points $1, 2, \ldots, x$ on a coordinate axis. You are given a collection of segments that start and end in these points. Each segment has weight and penalty associated with it.

Initially, you have a score of $0$. You can make moves. In each move, you select a segment from the given collection, remove it from the collection, and your score decreases by the penalty associated with the segment. In return, your score increases by the weight of the segment multiplied by the number of points with integer coordinates such that, at this moment of time, this segment is theonly segment in the collection that covers these points. A segment is considered to cover its endpoints.

The total score is the sum of scores for the moves you make. Find the maximum total score you can achieve.

입력

The first line contains an integer $t$ ($1 \le t \le 2 \cdot 10^5$), the number of test cases. The test cases follow.

The first line of each test case contains two integers: the number of segments $n$ ($1 \le n \le 2 \cdot 10^5$) and the maximum coordinate $x$ ($1 \le x \le 5 \cdot 10^5$).

Next $n$ lines contain the description of segments. Each line contains four integers: the start $\ell_i$ and end $r_i$ of the segment ($1 \le \ell_i \le r_i \le x$), its weight $w_i$ ($1 \le w_i \le 10^9$) and penalty $p_i$ ($1 \le p_i \le 10^9$).

The sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The sum of $x$ over all test cases does not exceed $5 \cdot 10^5$.

출력

For each test case, print a line containing one integer: the maximum possible score you can achieve.

제한

예제 입력 1

23 83 7 3 25 8 2 11 3 2 22 51 3 2 73 5 3 4

예제 출력 1

162

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 3: ABalobanov Contest 1 supported by Pinely B번

출처

대학교 대회

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


[8]ページ先頭

©2009-2025 Movatter.jp