#include int n; int w[101],dp[101]; int Max(int i,int j){ return i>j ? i:j; } /*i以降でrwを超えない最大のwを返す関数*/ int solver(int i,int rw){ if(dp[i] != -1) return dp[i]; else{ int res; if(i==n) res=0; else if(w[i]>rw){ res = solver(i+1,rw); } else{ res = Max(solver(i+1,rw),solver(i+1,rw-w[i])+w[i]); } dp[i] = res; return res; } } int main(void){ int j,sum=0; scanf("%d",&n); for(j=0;j