Submission #858540

#TimeUsernameProblemLanguageResultExecution timeMemory
858540serifefedartarCipele (COCI18_cipele)C++17
90 / 90
34 ms2896 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0); #define s second #define f first typedef long long ll; const ll MOD = 998244353; const ll LOGN = 18; const ll INF = 1e15; const ll MAXN = 3e5 + 5; int N, M; vector<int> A, B; bool check(int x) { int ptr = 0; for (int i = 0; i < N; i++) { if (ptr == M) return false; while (abs(A[i] - B[ptr]) > x) { ptr++; if (ptr == M) return false; } ptr++; } return true; } int main() { fast cin >> N >> M; A = vector<int>(N); B = vector<int>(M); for (int i = 0; i < N; i++) cin >> A[i]; for (int i = 0; i < M; i++) cin >> B[i]; sort(A.begin(), A.end()); sort(B.begin(), B.end()); if (N > M) { swap(N, M); swap(A, B); } int L = 0; int R = 1e9; int ans = -1; while (R >= L) { int mid = L + (R-L)/2; if (check(mid)) { ans = mid; R = mid - 1; } else L = mid + 1; } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...