Submission #756593

# Submission time Handle Problem Language Result Execution time Memory
756593 2023-06-12T01:04:48 Z Pring Cipele (COCI18_cipele) C++14
90 / 90
41 ms 1888 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int, int> pii;

const int MXN = 100005;
int n, m, a[MXN], b[MXN];
bool flag;
// bitset<MXN> bb;

bool check(int x) {
    int pa = 0;
    for (int pb = 0; pb < m; pb++) {
        while (pa < n && abs(b[pb] - a[pa]) > x) pa++;
        if (pa == n) return false;
        pa++;
    }
    return true;
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin >> n >> m;
    flag = (n >= m);
    if (flag) {
        for (int i = 0; i < n; i++) cin >> a[i];
        for (int i = 0; i < m; i++) cin >> b[i];
    } else {
        for (int i = 0; i < n; i++) cin >> b[i];
        for (int i = 0; i < m; i++) cin >> a[i];
        swap(n, m);
    }
    sort(a, a + n);
    sort(b, b + m);
    int l = -1, r = INT_MAX;
    while (l + 1 < r) {
        int mid = (l + r) >> 1;
        (check(mid) ? r : l) = mid;
    }
    cout << r << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1876 KB Output is correct
2 Correct 39 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1848 KB Output is correct
2 Correct 37 ms 1888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 1580 KB Output is correct
2 Correct 23 ms 1224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1620 KB Output is correct
2 Correct 16 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1492 KB Output is correct
2 Correct 30 ms 1632 KB Output is correct