求调
查看原帖
求调
1286053
Cute_QiQi楼主2024/11/20 21:10

111

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read()
{
    int x=0,F=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            F=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
        x=x*10+ch-'0',ch=getchar();
    return x*F;
}
void write(int x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
    return;
}
const int N=1E5+5;
int a[N], b[N], s, t, k, l, r=1e9;
bool work(int u)
{
	int tot=0;
	for(register int i=1; i<=s; ++i)
	{
		tot+=upper_bound(b+1, b+t+1, u-a[i])-b;
	}
	return k<=tot;
}
signed main(){
	//泥嚎,写题吧骚年
	s=read(), t=read(), k=read();
	for(register int i=1; i<=s; ++i)
	{
		a[i]=read();
	}
	for(register int i=1; i<=t; ++i)
	{
		b[i]=read();
	}
	stable_sort(b+1, b+t+1);
	while(l+1<r)
	{
		int mid=l+r>>1;
		work(mid)?r=mid:l=mid;
	}
	write(r);
	return 0;
}

2024/11/20 21:10
加载中...