Submission #894387

# Submission time Handle Problem Language Result Execution time Memory
894387 2023-12-28T08:22:18 Z vjudge1 Cipele (COCI18_cipele) C++17
0 / 90
24 ms 1164 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ppb pop_back()

const int N = (int)1e5 + 5;
const ll mod = (int)1e9 + 7;
const ll inf = (1e9) + 100;

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

bool ok(int k) {
    int j = 1;
    for (int i = 1; i <= min(n, m); i++) {
        if (n <= m) {
            while (j <= m && abs(a[i] - b[j]) > k) j++;
            if (j > m) return 0;
            j++;
        } else {
            while (j <= n && abs(a[j] - b[i]) > k) j++;
            if (j > n) return 0;
            j++;
        }
    }
    return 1;
}

void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
    }
    int l = 0, r = inf, ans = inf;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (ok(mid)) {
            r = mid - 1;
            ans = mid;
        } else l = mid + 1;
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int T = 1;
    //cin >> T;
    while (T--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1112 KB Output is correct
2 Incorrect 24 ms 1112 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 1088 KB Output isn't correct
2 Halted 0 ms 0 KB -