Problem C
Desire For Coffee
At campus Valla of Linköping University, the center of
attention is the building Kårallen (the Coral). A number of sea
turtles, inhabiting Kårallen, have been given an important task
— to deliver coffee to Lithe Kod, the hosts of Liu Challenge.
Since Kårallen has its own café, the sea turtles have no
problem getting their flippers on a few hot cups of Java, but
Lithe Kod resides in a completely different building. Sea
turtles live in water which means they cannot crawl efficiently
on land and get tired quickly. They do however have a solution
which allows them to crawl greater distances: stacking.
Given $N$ sea turtles,
where the $i$:th turtle
can carry $C_ i$ kg on top
of its shell, weighs $W_
i$ kg and can crawl $L_
i$ meters (independent of weight carried), how far can
the optimal turtle stack crawl?
Input
The first line of input contains an integer $N$ ($1 \leq N \leq 1000$), the number of sea turtles. Then follows $N$ lines, the $i$:th line ($1 \leq i \leq N$), describes turtle $i$ in the format ’$C_ i$ $W_ i$ $L_ i$’ with ($1 \leq $ $C_ i$, $W_ i$, $L_ i \leq 500$).
Output
Output a single integer descriing the total crawl distance of the optimal turtle stack.
Sample Input 1 | Sample Output 1 |
---|---|
5 4 26 10 25 5 2 25 5 1 25 5 1 25 5 5 |
10 |
Sample Input 2 | Sample Output 2 |
---|---|
5 4 2 10 25 7 3 25 8 4 25 10 2 25 9 5 |
22 |