QOJ.ac

QOJ

Límite de tiempo: 5 s Límite de memoria: 2048 MB Puntuación total: 25

#12416. 购物优惠

Estadísticas

你在一家商店购物,商店总共出售 $M$ 件商品。商店的布局可以建模为一个二维平面,其中第 $i$ 件商品位于点 $(x_i, y_i)$,价格为 $p_i$。

商店提供 $N$ 种购物优惠。第 $i$ 种优惠由一个点 $(a_i, b_i)$ 指定,花费 $c_i$ 即可获得以下四个区域中你所选择的恰好一个区域内的每一件商品:

  • 满足 $x \le a_i$ 且 $y \le b_i$ 的点 $(x, y)$ 区域。
  • 满足 $x \le a_i$ 且 $y \ge b_i$ 的点 $(x, y)$ 区域。
  • 满足 $x \ge a_i$ 且 $y \le b_i$ 的点 $(x, y)$ 区域。
  • 满足 $x \ge a_i$ 且 $y \ge b_i$ 的点 $(x, y)$ 区域。

每种购物优惠最多只能使用一次。商品也可以通过支付各自的价格 $p_i$ 单独购买。

你想要获得商店中每一件商品至少各一个。求你必须支付的最低总成本。

输入格式

第一行包含两个空格分隔的整数 $N$ 和 $M$。

接下来的 $N$ 行,每行包含三个空格分隔的整数 $a_i, b_i$ 和 $c_i$ ($-10^9 \le a_i, b_i \le 10^9, 1 \le c_i \le 10^9$)。

接下来的 $M$ 行,每行包含三个空格分隔的整数 $x_i, y_i$ 和 $p_i$ ($-10^9 \le x_i, y_i \le 10^9, 1 \le p_i \le 10^9$)。

下表显示了 25 分的分布情况:

分值 $N$ 的范围 $M$ 的范围 附加约束
3 分 $1 \le N \le 70$ $1 \le M \le 20$
3 分 $1 \le N \le 70$ $1 \le M \le 70$
4 分 $1 \le N \le 100$ $1 \le M \le 100\,000$ 任意两个点 $(a_i, b_i)$ 或 $(x_j, y_j)$ 的 $x$ 坐标或 $y$ 坐标均不相同
2 分 $1 \le N \le 100$ $1 \le M \le 100\,000$
8 分 $1 \le N \le 1\,000$ $1 \le M \le 100\,000$ 任意两个点 $(a_i, b_i)$ 或 $(x_j, y_j)$ 的 $x$ 坐标或 $y$ 坐标均不相同
4 分 $1 \le N \le 1\,000$ $1 \le M \le 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

说明 1

使用第一种购物优惠,选择区域 $\{(x, y) \mid x \le 1, y \ge 1\}$ 以获得第二件商品。然后,单独购买第 1、3 和 4 件商品。总成本为 $3 + (2 + 4 + 3) = 12$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.