#include <stdio.h>
#include <math.h>
int v[]={101,18,10,19,9120};
int  total(int i,int j)
{
int l,r,t;
if(i==-1||j==0) return 0;
l=total(i-1,j);r=total(i-1,j-v[i])+v[i];
t=fabs(l-j)<fabs(r-j) ?  l:r;

return t;
}


 
 
int main()
{

printf("total(5,35)=%d\n",total(5,130));

getchar();
return 0;
}