2020 CCPC Wannafly Winter Camp Day1 Div.1&amp F

 

 

 

 

#include<bits/stdc++.h>
 
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fore(i, s, t) for (int i = s; i < (int)t; i++)
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf(x) printf("%d\n",x)
#define each(x) for(auto it:x)  cout<<it<<endl;
#define pi pair<int,int>
 
using namespace std;
 
char inline nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
 
template <typename T>
bool rd(T& v){
    static char ch;
    while(ch!=EOF&&!isdigit(ch)) ch=nc();
    if(ch==EOF) return false;
    for(v=0;isdigit(ch);ch=nc())
        v=v*10+ch-'0';
    return true;
}
 
template <typename T>
void o(T p){
    static int stk[70],tp;
    if(p==0) {
        putchar('0');return ;
    }
    if(p<0) {
        p=-p;putchar('-');
    }
    while(p) stk[++tp]=p%10,p/=10;
    while(tp) putchar(stk[tp--]+'0');
}
 
typedef long long ll;
 
const int maxn=2e5+5;
const int maxm=4e5+5;
const int inf=1e9;
 
typedef vector<int> vc;
 
int n,m;
 
ll k;
 
bool xz(ll x,vc a,vc b){
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0)
            ans += x < 0 ? m : 0;
        else if (a[i] < 0) {
            ll  p = ceil(x * 1.0 / a[i]);
            ans += lower_bound(all(b),p) - b.begin();
        }
        else if (a[i] > 0) {
            ll p = floor(x * 1.0 / a[i]);
            ans += m - (upper_bound(all(b),p) - b.begin());
        }
    }
    return ans <= k;
}
 
int main(){
    cin>>n>>m>>k;
    k--;
    vector<int> a(n),b(m);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<m;i++)
        scanf("%d",&b[i]);
    sort(all(a));
    sort(all(b));
    ll l=-1e12,r=1e12;
    ll ans=l;
    while(l<r){
        ll mid=l+r>>1;
        if(xz(mid,a,b)) r=mid;
        else l=mid+1;
    }
    cout<<l<<endl;
}

  

posted on 2020-02-04 19:15  欣崽  阅读(211)  评论(0编辑  收藏  举报

导航