Submission #197863

# Submission time Handle Problem Language Result Execution time Memory
197863 2020-01-23T17:58:09 Z Osama_Alkhodairy Cipele (COCI18_cipele) C++17
90 / 90
53 ms 1184 KB
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, m;
vector <int> a, b;

bool check(int x){
    int pt = 0;
    for(auto &i : a){
        while(pt < m && b[pt] < i - x) pt++;
        if(pt == m) return 0;
        if(b[pt] - i > x) return 0;
        pt++;
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    a.resize(n);
    for(auto &i : a) cin >> i;
    b.resize(m);
    for(auto &i : b) cin >> i;
    if(m < n){
        swap(a, b);
        swap(n, m);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int l = 0, r = 1e9;
    while(l <= r){
        int mid = (l + r) / 2;
        if(check(mid)) r = mid - 1;
        else l = mid + 1;
    }
    cout << l << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1144 KB Output is correct
2 Correct 52 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 1160 KB Output is correct
2 Correct 53 ms 1184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 380 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1044 KB Output is correct
2 Correct 32 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 980 KB Output is correct
2 Correct 25 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1016 KB Output is correct
2 Correct 45 ms 1144 KB Output is correct