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