A12189 | The Fair Nut and Rectangles
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
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.
In the second example, the right answer can also be achieved by choosing the first and the second rectangles.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted