Submission #130970

#TimeUsernameProblemLanguageResultExecution timeMemory
130970LightningCipele (COCI18_cipele)C++14
90 / 90
53 ms2972 KiB
#include <iostream> #include <cmath> #include <algorithm> using namespace std; const int N = 2e5; const int INF = 1e9; int n, m, a[N], b[N]; bool check(int x) { int pos = 1; for(int i = 1; i <= n; ++i) { while(pos <= m && abs(a[i] - b[pos]) > x) { ++pos; } if(pos <= m && abs(a[i] - b[pos]) <= x) { ++pos; } else { return 0; } } return 1; } int main () { ios_base :: sync_with_stdio(false); cin >> n >> m; for(int i = 1; i <= n; ++i) { cin >> a[i]; } sort(a + 1, a + n + 1); for(int i = 1; i <= m; ++i) { cin >> b[i]; } sort(b + 1, b + m + 1); if(n > m) { for(int i = 1; i <= n; ++i) { swap(a[i], b[i]); } swap(n, m); } int l = 0, r = INF; while(l < r) { int mid = (l + r) / 2; if(check(mid)) r = mid; else l = mid + 1; } cout << r; return 0; }
#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...