Submission #756588

# Submission time Handle Problem Language Result Execution time Memory
756588 2023-06-12T01:00:46 Z Pring Cipele (COCI18_cipele) C++14
45 / 90
421 ms 596 KB
#include <bits/stdc++.h>
using namespace std;

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

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

bool check(int x) {
    bb.reset();
    for (int i = 0; i < m; i++) {
        bool flag = true;
        for (int j = 0; j < n; j++) {
            if (bb[j]) continue;
            if (abs(a[j] - b[i]) <= x) {
                bb[j] = true;
                flag = false;
                break;
            }
        }
        if (flag) return false;
    }
    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 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 114 ms 340 KB Output is correct
2 Correct 395 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 340 KB Output is correct
2 Correct 421 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 421 ms 376 KB Output is correct
2 Correct 384 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 297 ms 376 KB Output is correct
2 Correct 378 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 294 ms 380 KB Output is correct
2 Correct 366 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -