Submission #95405

#TimeUsernameProblemLanguageResultExecution timeMemory
95405dalgerokCipele (COCI18_cipele)C++14
90 / 90
42 ms2936 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, a[N], b[N], c[N]; inline bool check(int x){ for(int i = 1, j = 1; i <= n; i++, j++){ while(j <= m && a[i] - b[j] > x){ j += 1; } if(j > m || abs(a[i] - b[j]) > x){ return false; } } return true; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= m; i++){ cin >> b[i]; } sort(a + 1, a + n + 1); sort(b + 1, b + m + 1); if(n > m){ for(int i = 1; i <= n; i++){ c[i] = a[i]; } for(int i = 1; i <= m; i++){ a[i] = b[i]; } for(int i = 1; i <= n; i++){ b[i] = c[i]; } swap(n, m); } int l = 0, r = 1e9; while(r - l > 1){ int mid = (r + l) >> 1; if(check(mid)){ r = mid; } else{ l = mid; } } if(check(l)){ cout << l; } else{ cout << r; } }
#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...