#include #include using namespace std; #define NMAX 100 int N; int v[NMAX],w[NMAX]; int V; int minw,maxw; int minw2,maxw2; int minv,maxv; void nap1(int i,int vsum,int wsum){ if(i==N){ if(V==vsum){ minw=min(minw,wsum); maxw=max(maxw,wsum); } } for(int j=i;j=vsum){ maxw2=max(maxw2,wsum); minv=max(minv,vsum); } } } for(int j=i;j>N; int ansi,ansx; int minn=1000*100000,sumn=0; int minm=1000*100000,summ=0; for(int i=0;i>v[i]; cin>>w[i]; if(minn>v[i]) minn=v[i]; sumn+=v[i]; if(minm>w[i]) minm=w[i]; summ+=w[i]; } cin>>V; minw=1000*100000,maxw=-1; nap1(0,0,0); minw2=1000*100000,maxw2=-1; minv=-1,maxv=-1; nap2(0,0,0); if(V>minv) ansi=minw2; else ansi=minw2+1; if(minn>V) ansi=1; if(sumn==V) ansi=summ; if(V>maxv) ansx=maxw2; else ansx=maxw2-1; if(minn>V) ansx=minm-1; cout<