Codeforces Round 526 (Div. 1) |
---|

Finished |

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

data structures

dp

geometry

*2400

No tag edit access

The problem statement has recently been changed. View the changes.

×
E. The Fair Nut and Rectangles

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThe 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.

Examples

Input

3 4 4 8 1 5 0 5 2 10

Output

9

Input

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

Output

10

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.

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/07/2023 02:31:13 (j3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|