ZOJ 3278 8G Island 二分+二分
第K大,不是第K小啊 (╯‵□′)╯︵┻━┻
----------
int n,m; LL K; LL a[maxn],b[maxn]; bool C(LL x){ LL res=0; for (int i=1;i<=n;i++) { int l=1,r=m; LL ans=0; while (l<=r){ int mid=(l+r)/2; if (1LL*a[i]*b[mid]>=x){ ans=mid; l=mid+1; } else r=mid-1; } res+=ans; } return res>=K; } int main(){ while (cin>>n>>m>>K){ for (int i=1;i<=n;i++) cin>>a[i]; for (int i=1;i<=m;i++) cin>>b[i]; sort(a+1,a+n+1,greater<int>()); sort(b+1,b+m+1,greater<int>()); LL l=1LL*a[n]*b[m],r=1LL*a[1]*b[1]; LL ans=l; while (l<=r) { LL mid=(l+r)/2; if (C(mid)) { ans=mid; l=mid+1; } else r=mid-1; } cout<<ans<<endl; } return 0; }
----------