Submission #228182

# Submission time Handle Problem Language Result Execution time Memory
228182 2020-04-30T06:28:57 Z VEGAnn Cipele (COCI18_cipele) C++14
90 / 90
54 ms 2944 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int a[N], b[N], n, m;

bool ok(int x){
    int ptr = 0;

    for (int i = 0; i < n; i++){
        while (ptr < m && abs(a[i] - b[ptr]) > x)
            ptr++;

        if (ptr >= m) return 0;

        ptr++;
    }

    return 1;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m;

    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < m; i++)
        cin >> b[i];

    sort(a, a + n);
    sort(b, b + m);

    if (n > m){
        for (int i = 0; i < n; i++)
            swap(a[i], b[i]);
        swap(n, m);
    }

    int l = 0, r = int(1e9);

    while (l < r){
        int md = (l + r) >> 1;

        if (ok(md))
            r = md;
        else l = md + 1;
    }

    cout << l;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2688 KB Output is correct
2 Correct 50 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 2936 KB Output is correct
2 Correct 50 ms 2944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 488 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 2512 KB Output is correct
2 Correct 32 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2552 KB Output is correct
2 Correct 27 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2424 KB Output is correct
2 Correct 44 ms 2560 KB Output is correct