求调!!!样例已过
查看原帖
求调!!!样例已过
913288
3_14楼主2024/12/4 20:00
#include<bits/stdc++.h>
#define lcm(x,y) x/__gcd(x,y)*y;
#define str to_string
using namespace std;
using ll=long long;
const int MAX=1e5+1;
const double EPS=1e-6;
ll n,m,k,a[MAX],b[MAX];
bool check(ll mid,ll cnt=0){
	for(ll i=1;i<=n;i++)
		cnt+=(m-(upper_bound(b+1,b+1+m,mid-a[i])-(b+1)));
	return cnt>k;
}
void work(){
	ll l=a[1]+b[1],r=a[n]+b[m];
	while(l<=r){
		ll mid=(l+r)>>1;
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	cout<<r<<'\n';
}
int main(){
	cin>>n>>m>>k;
	for(ll i=1;i<=n;i++)cin>>a[i];
	for(ll i=1;i<=m;i++)cin>>b[i];
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);
	work();
	return 0;
}
2024/12/4 20:00
加载中...