i got this task last week but can't find a good algorithm to solve the problem. So here is the description:
You can build a stable tower with building bricks by not putting bigger bricks to smaller ones and if you don't put harder bricks into lighter ones. Make a programme which gives you the highest possible tower with n number of bricks.
In the first row of in.txt there is the number of cubes n (1 =<n =<1000). the following n line consisting two positive integer, a cube's sidelength and weight (both of them are not higher than 2000) there are no similar cubes which sidelength and wieght is the same
you have to write the highest possible stable tower's m number into out.txt. into the second row you have to write in the ordinal number m of the tower from bottom to top. by the height of the tower we mean the amount of all of the cubes's sidelength (not the number of cubes). if there are more than one solution, you can give whatever you want
example for input and output:
10 3 2 1 5
there are limits on the program. Time limit: 0.2 sec. Memory limit: 16 Mb
I hope you can help me to solve this, i need to finish this till sunday. thx for all help