#include #include #include #include using namespace std; typedef long long lint; typedef vectorvi; typedef pairpli; #define rep(i,n)for(int i=0;i<(int)(n);++i) int k,l,m,n; lint s; const int N=601; const int NLIMIT=600; const lint VLIMIT=30000; lint a[N],b[N],c[N],d[N]; void in_range(lint a,lint b,lint c){ assert(b<=a&&a<=c); } lint quo(lint a,lint b){ assert(b>0); lint q=a/b; if(a>k>>l>>m>>n>>s; rep(i,k)cin>>a[i]; rep(i,l)cin>>b[i]; rep(i,m)cin>>c[i]; rep(i,n)cin>>d[i]; //入力が妥当か確認する。 in_range(k,1,NLIMIT); in_range(l,1,NLIMIT); in_range(m,1,NLIMIT); in_range(n,1,NLIMIT); in_range(s,1,lint(k)*l*m*n); rep(i,k)in_range(a[i],-VLIMIT,VLIMIT); rep(i,l)in_range(b[l],-VLIMIT,VLIMIT); rep(i,m)in_range(c[m],-VLIMIT,VLIMIT); rep(i,n)in_range(d[n],-VLIMIT,VLIMIT); //平方分割 vectorfrm; vectorlat,latneg,latpos; lint lat0=0; rep(i,k)rep(j,l)frm.push_back(pli(a[i]*b[j],i*l+j)); rep(i,m)rep(j,n)lat.push_back(c[i]*d[j]); sort(frm.begin(),frm.end()); for(lint x:lat){ if(x>0)latpos.push_back(x); if(x<0)latneg.push_back(-x); if(x==0)lat0++; } sort(latpos.begin(),latpos.end()); sort(latneg.rbegin(),latneg.rend()); //二分探索。x 以下の要素が s 個以上になる最小の x が欲しい。 //8.1*10^17 を包む値 lint pass=1e18,fail=-1e18; while(pass-fail>1){ lint mid=fail+(pass-fail)/2; lint count=mid>=0?lat0*k*l:0; int pos=k*l; //尺取り if(mid>=0){ rep(i,latpos.size()){ lint div=latpos[i]; lint q=quo(mid,div); while(pos>0&&frm[pos-1].first>q)pos--; count+=pos; } pos=0; for(int i=(int)latneg.size()-1;i>=0;i--){ lint div=latneg[i]; lint q=quo(-mid+div-1,div); while(pos=0;i--){ lint div=latpos[i]; lint q=quo(mid,div); while(pos>0&&frm[pos-1].first>q)pos--; count+=pos; } pos=0; rep(i,latneg.size()){ lint div=latneg[i]; lint q=quo(-mid+div-1,div); while(pos=s)pass=mid; else fail=mid; } cout<