Submission #858539

#TimeUsernameProblemLanguageResultExecution timeMemory
858539serifefedartarCipele (COCI18_cipele)C++17
54 / 90
33 ms3412 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++) { 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...