logo AlgoBeat OnlineJudge
登录 注册

#213076. [CCO 2025] Shopping Deals

内存限制:2048 MiB 时间限制:5000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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

The store offers shopping deals. The -th shopping deal is specified by a point , and for a cost of , you can obtain one of every item within exactly one of the following four regions of your choice:

  • The region of points such that and .
  • The region of points such that and .
  • The region of points such that and .
  • The region of points such that and .

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

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 and .

The next lines of input each contain three space-separated integers, , , and (, ).

The next lines of input each contain three space-separated integers, , , and (, ).

输出格式

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

样例

样例输入 1

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

样例输出 1

12

数据范围与提示

Sample 1 Explanation

Use the first shopping deal on the region to obtain the second item. Then, purchase items 1, 3, and 4 individually. The total cost is .

The following table shows how the available marks are distributed:

Marks Awarded Bounds on Bounds on Additional Constraints
1 mark None
3 marks
4 marks No two points or have the same or -coordinate.
2 marks None
8 marks No two points or have the same or -coordinate.
4 marks None