All pastes #165843 Raw Edit

Casanova

public text v1 · immutable
·published 2006-09-10 06:47 UTC
rendered paste body
total = 0;
for (i=0; array[i] != NULL; i++)
     total += array[i];

array = sort(array);
mid = total/2;

dst = array.size();
for (i=0; i<dst; i++) {
     old=dst;
     for (j=i+1; j<old;j++) {
          if (array[i]+array[j] > mid)
               return total - array[j-1];
          else {
               array[dst] = array[i]+array[j];
               dst++;
          }
}