title: tower of boxes (stacking cubes)
body: <p>i got this task last week but can't find a good algorithm to solve the problem. So here is the description:</p>
  
  <p>You can build a stable tower with building cubes by not putting bigger cubes to smaller ones and if you don't put harder cubes into lighter ones. Make a programme which gives you the highest possible tower with n number of cubes.<br>
  Input:<br>
  In the first row of in.txt there is the number of cubes n (1 =&lt; n =&lt;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<br>
  Output:<br>
  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<br>
  example for input and output:<br>
  input:<br>
  5<br>
  10 3<br>
  20 5<br>
  15 6<br>
  15 1<br>
  10 2<br>
  and the output:<br>
  3<br>
  2 1 5<br>
  here are limits on the program. Time limit: 0.2 sec. Memory limit: 16 Mb  </p>
  
  <p>I hope you can help me to solve this. thx for all help  </p>