Page 1 of 1

PKU # 3003 - Spiderman’s workout

Posted: Tue Mar 03, 2009 4:21 pm
by slxst
Spiderman’s workout

I'm starting with:

Code: Select all

function workout(int h, vector<int> d, int idx) {
   if(idx == d.size()) { // There are no more distances
      return (h == 0) ? EXIT : FAIL; // Did I return to the ground?
   }
   if(h < d[i]) { // I can only go Up
      return workout(h + d[i], d, i+1);
   }
   return optimal(workout(h + d[i], d, i+1), workout(h - d[i], d, i+1)); // Return the optimal of going Up or Down
}
Is this going anywhere?

Thanks.