#include using namespace std; int sht[100][100001]; int main(void){ int N,V,v[100],w[100],i,j,W_max=0,temp,cnt=0,min=-1,max=-1; cin>>N; for(i=0;i>v[i]>>w[i]; W_max=W_max+w[i]; } cin>>V; for(i=0;i<100;i++){ for(j=0;j<100001;j++){ sht[i][j]=0; } } sht[w[0]][0]=v[0]; for(i=0;i<=W_max;i++){ for(j=1;j=0){ temp=sht[i-w[j]][j-1]+v[j]; if(sht[i][j-1]<=temp){ sht[i][j]=temp; }else{ sht[i][j]=sht[i][j-1]; } }else{ sht[i][j]=sht[i][j-1]; } } if(sht[i][N-1]==V){ cnt++; if(cnt==1) min=i; } if(sht[i][N-1]>V){ max=i-1; break; } } if(min==0) min=1; if(min==-1) min=W_max; cout<