CF1083E.The Fair Nut and Rectangles

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Fair Nut got stacked in planar world. He should solve this task to get out.

You are given nn rectangles with vertexes in (0,0)(0, 0), (xi,0)(x_i, 0), (xi,yi)(x_i, y_i), (0,yi)(0, y_i). For each rectangle, you are also given a number aia_i. Choose some of them that the area of union minus sum of aia_i of the chosen ones is maximum.

It is guaranteed that there are no nested rectangles.

Nut has no idea how to find the answer, so he asked for your help.

公平的坚果被困在了一个平面世界中。他必须解决这个问题才能脱身。

给你 nn 个矩形,每个矩形的四个顶点分别为 (0,0)(0, 0)、(xi,0)(x_i, 0)、(xi,yi)(x_i, y_i) 和 (0,yi)(0, y_i)。对每个矩形,你还给定一个数 aia_i。你需要从中选出若干个矩形,使得这些矩形的并集面积减去所选矩形对应 aia_i 的总和达到最大值。

题目保证不存在互相嵌套的矩形(即任意两个矩形均不满足一个完全包含于另一个之内)。

坚果完全不知道如何求解,因此向你求助。

输入格式

The first line contains one integer nn (1≤n≤1061 \leq n \leq 10^6) — the number of rectangles.

Each of the next nn lines contains three integers xix_i, yiy_i and aia_i (1≤xi,yi≤1091 \leq x_i, y_i \leq 10^9, 0≤ai≤xi⋅yi0 \leq a_i \leq x_i \cdot y_i).

It is guaranteed that there are no nested rectangles.

第一行包含一个整数 nn(1≤n≤1061 \leq n \leq 10^6)—— 矩形的数量。

接下来的 nn 行中,每行包含三个整数 xix_i、yiy_i 和 aia_i(1≤xi,yi≤1091 \leq x_i, y_i \leq 10^9,0≤ai≤xi⋅yi0 \leq a_i \leq x_i \cdot y_i)。

保证不存在嵌套的矩形。

输出格式

In a single line print the answer to the problem — the maximum value which you can achieve.

在一行中输出问题的答案——你能达到的最大值。

输入输出样例

  • 输入#1

    3
    4 4 8
    1 5 0
    5 2 10

    输出#1

    9
  • 输入#2

    4
    6 2 4
    1 6 2
    2 4 3
    5 3 8

    输出#2

    10

说明/提示

In the first example, the right answer can be achieved by choosing the first and the second rectangles.

In the second example, the right answer can also be achieved by choosing the first and the second rectangles.

在第一个例子中,通过选择第一个和第二个矩形可以得到正确答案。

在第二个例子中,通过选择第一个和第二个矩形也可以得到正确答案。

输入解题思路,AI测评打分。不知道怎么写?

首页