Submission #743570

# Submission time Handle Problem Language Result Execution time Memory
743570 2023-05-17T13:59:04 Z TudorMa Cipele (COCI18_cipele) C++14
54 / 90
85 ms 2848 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;
    }

    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 73 ms 2488 KB Output is correct
2 Correct 84 ms 2848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 2832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 5 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 2336 KB Output is correct
2 Correct 51 ms 1768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 2576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 76 ms 2288 KB Output is correct
2 Incorrect 73 ms 2464 KB Output isn't correct
3 Halted 0 ms 0 KB -