Codeforces Round 526 (Div. 1)
E
The Fair Nut and Rectangles
Codeforces
2400
原题
← DF →
翻译中…

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.

翻译中…

Input

翻译中…

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.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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 #1
3
4 4 8
1 5 0
5 2 10
Output #1
9
InputCopy OutputCopy
Input #2
4
6 2 4
1 6 2
2 4 3
5 3 8
Output #2
10
InputCopy OutputCopy
题目信息
题号
1083E
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划
计算几何

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。