답안 #699615

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699615 2023-02-17T13:57:06 Z wcwu Cipele (COCI18_cipele) C++17
90 / 90
126 ms 3680 KB
#include <bits/stdc++.h>
//#include<random>
using namespace std;
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("O3")*/
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")//for codeforces*/
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;
typedef map<ll, ll> mll;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int iINF=INT_MAX;
const ll INF=LLONG_MAX;
const ld PI=3.14159265358979323846;
ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);}
ll fpow(ll a,ll b,ll m) {
    if(!b) return 1;
    ll ans=fpow(a*a%m,b/2,m);
    return (b%2?ans*a%m:ans);
}
ll inv(ll a,ll m) {return fpow(a,m-2,m);}
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define dbg(n) cerr<<#n<<": "<<n<<"\n";
#define optline cout<<"\n";
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define irep(i,m,n) for(ll i=m;i>=n;i--)
#define F first
#define S second
#define All(c) c.begin(), c.end()
#define pb push_back
#define eb emplace_back
//#define mp make_pair
#define uni(c) c.resize(distance(c.begin(), unique(c.begin(), c.end())))
#define unisort(c) sort(c.begin(), c.end());uni(c)

ll n, m;
vector<ll> a, b;
bool check(ll x) {
    ll cur=0;
    rep(i, n) {
        ll d=lower_bound(b.begin()+cur, b.end(), a[i]-x)-b.begin();
        if(d==m) return false;
        if(b[d]-a[i]>x) {
            return false;
        }
        cur=d+1;
    }
    return true;
}

signed main() {
    IOS
    cin>>n>>m;
    a.resize(n);
    b.resize(m);
    rep(i, n) {
        cin>>a[i];
    }
    rep(i, m) cin>>b[i];
    sort(All(a));
    sort(All(b));
    if(n>m) {
        swap(n, m);
        swap(a, b);
    }
    ll l=0, r=1e18;
    rep(i, 100) {
        ll mid=(l+r)>>1;
        if(check(mid)) r=mid;
        else l=mid;
    }
    cout<<r<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 1996 KB Output is correct
2 Correct 126 ms 3680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 123 ms 1876 KB Output is correct
2 Correct 125 ms 3656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 7 ms 584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 6 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 7 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 392 KB Output is correct
2 Correct 6 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 1492 KB Output is correct
2 Correct 72 ms 2244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 115 ms 1700 KB Output is correct
2 Correct 47 ms 2512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 1492 KB Output is correct
2 Correct 107 ms 3176 KB Output is correct