Submission #743584

# Submission time Handle Problem Language Result Execution time Memory
743584 2023-05-17T14:11:46 Z TudorMa Cipele (COCI18_cipele) C++14
90 / 90
106 ms 2764 KB
#include <iostream>
#include <algorithm>

using namespace std;

int n, m, a[100001], b[100001];

bool ver(int x) {
    int i = 0, j = 0;
    while(i < n && j < m) {
        i++;
        j++;
        while(a[i] - x > b[j] && j < m)
            j++;

        if(a[i] - x > b[j] || a[i] + x < b[j])
            return 0;
    }

    if(i < n)
        return 0;

    return 1;
}

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

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

    int st = 0, dr = 1e9, ans = 0;
    while(st <= dr) {
        int mij = (st + dr) / 2;
        if(ver(mij)) {
            ans = mij;
            dr = mij - 1;
        }
        else
            st = mij + 1;
    }

    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 83 ms 1732 KB Output is correct
2 Correct 106 ms 1832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 1832 KB Output is correct
2 Correct 94 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 5 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 5 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 364 KB Output is correct
2 Correct 5 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 324 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 1624 KB Output is correct
2 Correct 56 ms 1504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 1748 KB Output is correct
2 Correct 54 ms 1960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 1628 KB Output is correct
2 Correct 88 ms 1848 KB Output is correct