#P6771. [USACO05MAR] Space Elevator 太空电梯

[USACO05MAR] Space Elevator 太空电梯

Problem Description

The cows are going to space. They plan to build a space elevator using blocks. There are NN types of blocks. Type ii has a fixed height hih_i and a certain quantity cic_i. To prevent cosmic rays from damaging the blocks, no part of any block of type ii may exceed height aia_i.
Please use these blocks to stack the tallest possible space elevator.

Input Format

The first line contains an integer NN.
Lines 22 to N+1N+1: the (i+1)(i+1)-th line contains three integers hi,ai,cih_i, a_i, c_i, separated by spaces.

Output Format

One line containing one integer: the height of the space elevator.

3
7 40 3
5 23 8
2 52 6

48

Hint

Constraints for 100%100\% of the testdata: 1N4001 \le N \le 400, 1hi1001 \le h_i \le 100, 1ci101 \le c_i \le 10, 1ai4×1041 \le a_i \le 4 \times 10^4.

Translated by ChatGPT 5