Submission #472385

# Submission time Handle Problem Language Result Execution time Memory
472385 2021-09-13T12:46:02 Z BidoTeima Cipele (COCI18_cipele) C++17
18 / 90
874 ms 10468 KB
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define tc int tttttt;cin>>tttttt;while(tttttt--)
#define sumrange(l,r,arr) (l==0?arr[r]:arr[r]-arr[l-1])
bool isint(const string& s){
    bool ok=1;
    for(char i:s)
        ok&=isdigit(i);
    return ok;
}
bool isseq(const string& s){
    return !isint(s);
}
int main(){
    ACPLS();
    int n,m;
    cin>>n>>m;
    if(n<m)swap(n,m);
    ll a[n];
    for(auto&i:a)cin>>i;
    multiset<ll>b;
    for(int i = 0; i < m; i++){
        ll x;
        cin>>x;
        b.insert(x);
    }
    ll lo=0,hi=1e18,ans=hi;
    sort(a,a+n);
    while(lo<=hi){
        ll mid=(lo+hi)/2;
        multiset<ll>ms=b;
        bool ok = 1;
        for(int i = 0; i < n; i++){
            if(ms.empty())break;
            auto it = ms.lower_bound(a[i]-mid);
            if(it==ms.end()||abs((*it)-a[i])>mid){
                ok=0;
                break;
            }
            ms.erase(it);
        }
        if(ok){
            ans=mid;
            hi=mid-1;
        }else lo=mid+1;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 595 ms 10464 KB Output is correct
2 Correct 874 ms 10468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 856 ms 10460 KB Output is correct
2 Correct 786 ms 10460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 480 ms 7212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 716 ms 8940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 482 ms 7284 KB Output isn't correct
2 Halted 0 ms 0 KB -