Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
316670 threebody1 最大的和 T5 C++ 通过 13 MS 1680 KB 2909 2026-04-16 11:32:53

Tests(10/10):


#include<bits/stdc++.h> #define lc p<<1 #define rc p<<1|1 #define ll long long #define spp(a) sort(a.begin(),a.end()) #define pll pair<ll,ll> #define mll map<ll,ll> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define eps 1e-6 double pi=3.14159265; //#define endl '\n' #define l128 __ll128 using namespace std; ll mod = 1e9+7; //template<typename U,typename V>U min(U x,const V y){return x<y?x:y;}; //template<typename U,typename V>U max(U x,const V y){return x>y?x:y;}; template<typename U,typename V>bool cmin(U &x , const V y){ return x>y?x=y,1:0;} template<typename U,typename V>bool cmax(U &x , const V y){ return x<y?x=y,1:0;} bool ifsu(ll x) { if (x == 1)return 0; for (ll i = 2; i <= sqrt(x); i++) { if (x % i == 0) { return 0; } } return 1; } ll gcd(ll x, ll y) { return y == 0 ? x : gcd(y, x % y); } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } ll qpow(ll x,ll n){ll ans=1;for(;n;n>>=1,x*=x,x%=mod)if(n&1)ans*=x,ans%=mod;return ans;} template<typename U,typename V>U qpow(U x,V n){U y(1);for(;n;n>>=1,x*=x)if(n&1)y*=x;return y;} struct ml{ ll x; ml():x(){} template<typename T>ml(T x):x((x%=mod)<0?x+mod:x){} ml inv()const{return qpow(*this,mod-2);} ml operator-()const{return ml(-x);} ml &operator+=(const ml &t){return (x+=t.x)<mod?0:x-=mod,*this;} ml &operator-=(const ml &t){return (x-=t.x)<0?x+=mod:0,*this;} ml &operator*=(const ml &t){return x=(ll)(x)*t.x%mod,*this;} ml &operator/=(const ml &t){return *this*=t.inv();} operator ll()const{return x;} bool operator==(const ml &t)const{return x==t.x;} template<typename T>ml operator+(const T &t){return ml(*this)+=t;} template<typename T>ml operator-(const T &t){return ml(*this)-=t;} template<typename T>ml operator*(const T &t){return ml(*this)*=t;} template<typename T>ml operator/(const T &t){return ml(*this)/=t;} template<typename T>friend ml operator+(const T &x,const ml &y){return ml(x)+=y;} template<typename T>friend ml operator-(const T &x,const ml &y){return ml(x)-=y;} template<typename T>friend ml operator*(const T &x,const ml &y){return ml(x)*=y;} template<typename T>friend ml operator/(const T &x,const ml &y){return ml(x)/=y;} friend istream &operator>>(istream &is,ml &t){ll x;is>>x;t=ml(x);return is;} friend ostream &operator<<(ostream &os,const ml &t){return os<<t.x;} }; void ji(){ ll n,k; cin>>n>>k; set<ll>s; for(ll i=0;i<n;i++){ ll x;cin>>x; s.insert(x); } ll ans=-1e18; for(ll i=0;i<n;i++){ ll x;cin>>x; auto y=s.upper_bound(x+k); if(y!=s.begin())--y; if(abs(*y-x)<=k)cmax(ans,*y+x); } if(ans!=-1e18)cout<<ans<<endl; else cout<<"None"<<endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); ll t=1; //cin>>t; for(ll i=1;i<=t;i++)ji(); return 0; } /* COWWCOCOWWCO OWC */ /* 551097717 */


测评信息: