【题目分析】
二分答案?smg,我太弱了
//不开longlong wa到挺了 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define ll long long const int maxn=200010; ll ans=0; ll n,m,k; ll a[maxn],b[maxn]; ll check(ll x)//找比x大的数有多少个 { ll cnt=0,p=m; for(int i=1;i<=n;i++)//枚举每一行有多少个比x小的数 { while((ll)a[i]*b[p]>x&&p)//这里p不需要重置为m,因为ab数组sort过,某一行一定比前一行里找到的p的位置要靠前或者一样 p--; cnt+=p; } return cnt; } int main() { freopen("number.in","r",stdin); freopen("number.out","w",stdout); scanf("%I64d%I64d%I64d",&n,&m,&k); for(int i=1;i<=n;i++) scanf("%I64d",&a[i]); for(int i=1;i<=m;i++) scanf("%I64d",&b[i]); sort(a+1,a+n+1); sort(b+1,b+m+1); ll l=0,r=a[n]*b[m]; while(l<=r) { ll mid=(l+r)>>1; if(check(mid)>=k)//如果比mid比实际答案要大 ans=mid, r=mid-1; else l=mid+1; } cout<<ans; fclose(stdin);fclose(stdout); return 0; }