Submission #919624

# Submission time Handle Problem Language Result Execution time Memory
919624 2024-02-01T09:13:19 Z mariamp1 Cipele (COCI18_cipele) C++14
90 / 90
69 ms 2956 KB
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
int n, m, a[N], b[N];
bool check(int x) {
    int ptr = 1;
    for (int i = 1; i <= n; i++) {
        while (ptr <= m && a[i] - x > b[ptr]) ptr++;
        if (ptr == m + 1 || a[i] + x < b[ptr]) return false;
        ptr++;
    }
    return true;
}
int main() {
    cin >> n >> m;
    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);
    if (n > m) {
        swap(n, m);
        for (int i = 1; i < N; i++) swap(a[i], b[i]);
    }
    int l = 0, h = 1e9, ans = 0;
    while (l <= h) {
        int mid = (l + h) / 2;
        if (check(mid)) {
            ans = mid; h = mid - 1;
        }
        else l = mid + 1;
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 63 ms 1104 KB Output is correct
2 Correct 68 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 1000 KB Output is correct
2 Correct 67 ms 2956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 5 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 472 KB Output is correct
2 Correct 4 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 1236 KB Output is correct
2 Correct 40 ms 2232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 1108 KB Output is correct
2 Correct 38 ms 2128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 848 KB Output is correct
2 Correct 57 ms 2732 KB Output is correct