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

34528번 - Shopping Deals 서브태스크다국어

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

문제

You are shopping from a store that sells a total of $M$ items. The store layout can be modelled as a two-dimensional plane, where the $i$-th item is located at the point $(x_i , y_i)$ and has a price of $p_i$.

The store offers $N$ shopping deals. The $i$-th shopping deal is specified by a point $(a_i , b_i),ドル and for a cost of $c_i,ドル you can obtain one of every item within exactly one of the following four regions of your choice:

  • The region of points $(x, y)$ such that $x ≤ a_i$ and $y ≤ b_i$.
  • The region of points $(x, y)$ such that $x ≤ a_i$ and $y ≥ b_i$.
  • The region of points $(x, y)$ such that $x ≥ a_i$ and $y ≤ b_i$.
  • The region of points $(x, y)$ such that $x ≥ a_i$ and $y ≥ b_i$.

Each shopping deal can only be used at most once. Items can also be purchased individually by paying their respective price $p_i$.

You want to obtain at least one of each item in the store. Find the minimum total cost you must pay to do so.

입력

The first line of input contains two space-separated integers $N$ and $M$.

The next N lines of input each contain three space-separated integers, $a_i,ドル $b_i,ドル and $c_i$ ($−10^9 ≤ a_i , b_i ≤ 10^9,ドル 1ドル ≤ c_i ≤ 10^9$).

The next M lines of input each contain three space-separated integers, $x_i$ , $y_i$ , and $p_i$ ($−10^9 ≤ x_i , y_i ≤ 10^9,ドル 1ドル ≤ p_i ≤ 10^9$).

출력

On a single line, output the minimum total cost that you must pay to obtain at least one of each item.

제한

서브태스크

번호배점제한
11

1ドル ≤ N ≤ 8,ドル 1ドル ≤ M ≤ 20$

23

1ドル ≤ N ≤ 70,ドル 1ドル ≤ M ≤ 20$

33

1ドル ≤ N ≤ 70,ドル 1ドル ≤ M ≤ 70$

44

1ドル ≤ N ≤ 100,ドル 1ドル ≤ M ≤ 100,円 000$ No two points $(a_i , b_i)$ or $(x_j , y_j )$ have the same $x$ or $y$-coordinate.

52

1ドル ≤ N ≤ 100,ドル 1ドル ≤ M ≤ 100,円 000$

68

1ドル ≤ N ≤ 1,円 000,ドル 1ドル ≤ M ≤ 100,円 000$ No two points $(a_i , b_i)$ or $(x_j , y_j )$ have the same $x$ or $y$-coordinate.

74

1ドル ≤ N ≤ 1,円 000,ドル 1ドル ≤ M ≤ 100,円 000$

예제 입력 1

2 4
1 1 3
3 3 13
0 0 2
0 2 5
2 0 4
2 2 3

예제 출력 1

12

Use the first shopping deal on the region $\{(x, y) | x ≤ 1, y ≥ 1\}$ to obtain the second item. Then, purchase items 1ドル,ドル 3ドル,ドル and 4ドル$ individually. The total cost is 3ドル + (2 + 4 + 3) = 12$.

노트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2025 > CCO 2025 6번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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