• 个人简介

    我的洛谷 yy yy yz

    yz yz yz

    #include<bits/stdc++.h>
    using namespace std;
    long long maxn=LONG_LONG_MIN,a[2000010],b[2000010],n,d,ai,bi;
    bool p=false;
    bool cmp(long long x,long long y){
    	return x>y;
    }
    int main(){
    	freopen("max.in","r",stdin);
    	freopen("max.out","w",stdout);	
    	ios::sync_with_stdio(false);
    	cin>>n>>d;
    	for(int i=1;i<=n;i++) cin>>a[i];
    	for(int i=1;i<=n;i++) cin>>b[i];
    	sort(a+1,a+n+1,cmp);
    	sort(b+1,b+n+1,cmp);
    	ai=1;
    	bi=1;
    	while(ai!=n&&bi!=n){
    		if(abs(a[ai]-b[bi])<=d){
    			maxn=max(a[ai]+b[bi],maxn);
    			p=true;
    			break;
    		} 
    		else{
    			if(bi==n) ai++,bi=1;
    			else bi++;
    		}
    	}
    	if(p==false) cout<<"None";
    		else cout<<maxn;
    }
    
    
    ios::sync_with_stdio(false);
    
  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

    This person is lazy and didn't write any solutions.