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

20579번 - Territories 다국어

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

문제

This time Byteasar researches a wildlife in a nature reserve that has a shape of an $X \times Y$ rectangle. It is divided into $XY$ unit squares, there is a square with coordinates $(x, y)$ for every 1ドル \le x \le X$ and 1ドル \le y \le Y$.

Our hard-working researcher distinguished $n$ species of animals and discovered that each species dislikes living on some particular rectangle (which is stricly smaller than whole nature reserve). For species number $i$ it is rectangle described by its two opposite corners $(x_i, y_i)$ and $(x'_i, y'_i),ドル for some $x_i \leq x'_i$ and $y_i \leq y'_i$. We know that there are $c_i$ animals in that species. Therefore, there are $S = c_1 + c_2 + \ldots + c_n$ animals in total.

Byteasar has an idea for a social-natural experiment which relies on putting each of $S$ animals in some cell outside of its disliked region. Sociality of a placement is a number of pairs of animals so that both of them are in the same cell. Hence, if a cell contains $p$ animals, this adds $\frac{p(p-1)}{2}$ to the overall sociality.

It is allowed to put animals from the same species into different cells.

Find the maximum value of the sociality that can be attained.

입력

The first line of input contains three integers $n,ドル $X$ and $Y$ (1ドル \leq n \leq 100,000円,ドル 1ドル \leq X,Y \leq 1000$) denoting the number of species and dimensions of nature reserve, respectively.

Each of following $n$ lines contains a description of species, $i$-th of them contains five integers $x_i, y_i, x'_i, y'_i, c_i$ (1ドル \leq x_i \leq x'_i \leq X,ドル 1ドル \leq y_i \leq y'_i \leq Y,ドル 1ドル \leq c_i \leq 1000$) describing region disliked by species number $i$ and number of animals in that species. For each $i$ at least one of the following conditions holds: $x_i \neq 1,ドル $y_i \neq 1,ドル $x'_i \neq X,ドル $y'_i \neq Y$

출력

You need to print one integer -- the maximum possible sociality of some placement.

제한

예제 입력 1

2 1 2
1 1 1 1 3
1 2 1 2 4

예제 출력 1

9

예제 입력 2

3 7 3
1 1 3 3 1
5 1 7 3 1
3 2 5 3 1

예제 출력 2

3

힌트

In first sample we need to put four animals in a cell $(1, 1)$ (contributing $\frac{4 \cdot 3}{2} = 6$ to the sociality) and put three remaining animals in a cell $(1, 2)$ (contributing $\frac{3 \cdot 2}{2} = 3$ to the sociality).

Second sample test is depicted below. All animals can be put in a cell $(4, 1)$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2020 > Day 1: Warsaw U Contest C번

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

출처

대학교 대회

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

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