305741: CF1083E. The Fair Nut and Rectangles

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

The Fair Nut and Rectangles

题意翻译

给定 $n$ 个平面直角坐标系中左下角为坐标原点,右上角为 $(x_i, y_i)$ 的矩形,每一个矩形拥有权值 $a_i$,且保证任意两个矩形的面积不会出现包含关系。你的任务是选出若干个矩形,使得选出的矩形的面积并减去矩形的权值之和尽可能大。输出最大值。 $1 \leq n \leq 10^6, 1 \leq x_i, y_i \leq 10^9, 0 \leq a_i \leq x_i \cdot y_i$,给出的矩形保证任意两个矩形的面积不会出现包含关系。

题目描述

The Fair Nut got stacked in planar world. He should solve this task to get out. You are given $ n $ rectangles with vertexes in $ (0, 0) $ , $ (x_i, 0) $ , $ (x_i, y_i) $ , $ (0, y_i) $ . For each rectangle, you are also given a number $ a_i $ . Choose some of them that the area of union minus sum of $ a_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.

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 1 \leq n \leq 10^6 $ ) — the number of rectangles. Each of the next $ n $ lines contains three integers $ x_i $ , $ y_i $ and $ a_i $ ( $ 1 \leq x_i, y_i \leq 10^9 $ , $ 0 \leq a_i \leq x_i \cdot y_i $ ). It is guaranteed that there are no nested rectangles.

输出格式


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.

Input

题意翻译

给定 $n$ 个平面直角坐标系中左下角为坐标原点,右上角为 $(x_i, y_i)$ 的矩形,每一个矩形拥有权值 $a_i$,且保证任意两个矩形的面积不会出现包含关系。你的任务是选出若干个矩形,使得选出的矩形的面积并减去矩形的权值之和尽可能大。输出最大值。 $1 \leq n \leq 10^6, 1 \leq x_i, y_i \leq 10^9, 0 \leq a_i \leq x_i \cdot y_i$,给出的矩形保证任意两个矩形的面积不会出现包含关系。

加入题单

上一题 下一题 算法标签: