Under construction

Still being built. Things may change

Recipe

Time limit1sMemory limit1024 MB

Summary
Given N ingredients with amounts at home, amounts needed, and unit prices, the task is to sum the cost of the missing amounts.
Level

Easy1 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

You have decided to cook. The dish needs NN ingredients. For each ingredient, you know how much you already have at home, how much the recipe needs in total, and the price of one unit if you have to buy it. You buy exactly the amount you are missing. Compute the total cost of the ingredients.

Input

The first line contains an integer NN (1≤N≤51 \le N \le 5), the number of ingredients.

Each of the next NN lines contains three integers H,B,KH, B, K (0≤H,B≤1 0000 \le H, B \le 1\,000, 1≤K≤1 0001 \le K \le 1\,000): the amount you have, the amount needed, and the cost of one unit.

Output

Print a single integer, the total cost of the ingredients.

Examples1

  1. Example 1

    Input
    3
    10 5 1000
    0 4 5
    2 5 1
    
    Expected output
    23