zoukankan      html  css  js  c++  java
  • 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
    ",x,y)
    #define pf(x) printf("%d
    ",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;
    }
    

      

  • 相关阅读:
    flask路由+视图
    flask基本使用1
    返回对象时字典化
    python3连接redis
    selected_related和prefetch_related
    django删除migrations导致初始化数据库失效
    vue添加拦截器(身份认证)以及cookie认证
    vue添加使用全局变量
    列表:动手试一试
    转来的字符串编辑方式
  • 原文地址:https://www.cnblogs.com/033000-/p/12260656.html
Copyright © 2011-2022 走看看