Canadian Computing Olympiad: 2025 Day 2, Problem 3
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.
Input Specification
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
.
The following table shows how the available 25 marks are distributed:
Marks Awarded | Bounds on |
Bounds on |
Additional Constraints |
---|---|---|---|
1 mark | None | ||
3 marks | None | ||
3 marks | None | ||
4 marks | No two points | ||
2 marks | |
None | |
8 marks | No two points | ||
4 marks | None |
Output Specification
On a single line, output the minimum total cost that you must pay to obtain at least one of each item.
Sample Input
2 4
1 1 3
3 3 13
0 0 2
0 2 5
2 0 4
2 2 3
Sample Output
12
Explanation for Sample Output
Use the first shopping deal on the region
to obtain the second item. Then,
purchase items
,
, and
individually. The total cost is
.
Comments