Hide

Problem F
Load

Languages en is

One way to assess how much work is done in the gym is the load of the workout. The load encompasses how much weight is lifted in total.

When you are in the gym you perform exercises. For each exercise you perform a particular number of sets and for each set you perform a particular number of repetitions. If you perform $k$ sets of $m$ repetition you perform the exercise a total of $k \dots m$ times. If the exercise is performed with $w$ kilos of weight the total load of the exercise is $k \cdot m \cdot w$.

You have just returned from the gym, but you are not satisfied with your performance. You want to rearrange the weights you lifted to impress your friends. What is the maximum total load you can create from your trip to the gym?

Explanation of sample input $1$

Initially your total load was $2 \cdot 15 \cdot 7 + 3 \cdot 8 \cdot 50 + 3 \cdot 6 \cdot 50 + 1 \cdot 3 \cdot 110 = 2640$. But if you swap the weights of your first and fourth exercises you get $2 \cdot 15 \cdot 110 + 3 \cdot 8 \cdot 50 + 3 \cdot 6 \cdot 50 + 1 \cdot 3 \cdot 7 = 5421$.

Input

The first line of the input contains a single integer $n$ ($1 \leq n \leq 10^5$). Then follow $n$ lines, each containing three integers $k$, $m$, and $w$ ($1 \leq k, m \leq 100$, $1 \leq w \leq 10^5$). Each line corresponds to an exercise you did in the gym where $k$ is the number of sets, $m$ is the number of repetitions, and $w$ is the weight you lifted.

Output

The output should contain a single integer, the maximum total load you can attain by rearranging the weights.

Sample Input 1 Sample Output 1
4
2 15 7
3 8 50
3 6 50
1 3 110
5421
Sample Input 2 Sample Output 2
2
4 6 30
4 3 60
1800
Sample Input 3 Sample Output 3
5
3 8 50
4 6 20
4 6 30
3 1 200
3 15 5
11415
Sample Input 4 Sample Output 4
3
100 100 100000
100 100 100000
100 100 100000
3000000000

Please log in to submit a solution to this problem

Log in