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

19427번 - Rectangles Inside Rectangle 다국어

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

문제

Bobo has a large rectangle with lower left and upper right corners at $(0, 0)$ and $(w, 10^6)$. He also has $n$ small axis-parallel rectangles inside the large rectangle. The weight of the $i$-th rectangle is $v_i$. For each rectangle, either its left border or its right border (but not both) coincides with the left or right side of the large rectangle.

Bobo would like to choose a subset of small rectangles in such a manner that the rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle). Among all the possibilities, he wants the one with the maximum possible sum of weights.

입력

The input contains zero or more test cases, and is terminated by end-of-file. For each test case:

The first line contains two integers $n$ and $w$ (1ドル \leq n \leq 2000,ドル 2ドル \leq w \leq 10^6$) denoting the number of small rectangles and the width of the large rectangle.

The $i$-th of the following $n$ lines contains five integers $\mathit{type}_i,ドル $l_i,ドル $a_i,ドル $b_i$ and $v_i$ ($\mathit{type}_i \in \{0, 1\},ドル 0ドル \leq a_i < b_i \leq 10^6,ドル 1ドル \leq l_i < w,ドル 0ドル \leq v_i \leq 10^6$) where $v_i$ is the weight of the $i$-th rectangle. Here, $\mathit{type}_i = 0$ means the lower left and upper right corner of the $i$-th rectangle are $(0, a_i)$ and $(l_i, b_i),ドル while $\mathit{type}_i = 1$ means the lower left and upper right corner of the $i$-th rectangle are $(w - l_i, a_i)$ and $(w, b_i)$.

It is guaranteed that for all 1ドル \leq i < j \leq n,ドル $a_i \ne a_j,ドル $a_i \ne b_j,ドル $b_i \ne a_j$ and $b_i \ne b_j$. Additionally, the sum of all $n$ does not exceed 2000ドル$.

출력

For each test case, output an integer which denotes the maximum sum of weights.

제한

예제 입력 1

3 10
0 3 1 6 12
0 3 3 4 100
1 9 2 5 11
3 10
0 3 1 6 12
0 1 3 4 5
1 9 2 5 11
6 5
1 1 17 32 4
0 3 1 18 7
1 3 4 8 12
1 2 15 20 14
1 1 30 33 16
1 4 2 16 13

예제 출력 1

100
16
42

힌트

For the third test, Bobo can choose the 3ドル$-rd, 4ドル$-th and 5ドル$-th rectangles.

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 9. Xi Lin Contest, Grand Prix of China F번

Contest > Open Cup > 2016/2017 Season > Stage 11: Grand Prix of China F번

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

출처

대학교 대회

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

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