Submission #170328

#TimeUsernameProblemLanguageResultExecution timeMemory
170328ngmhCipele (COCI18_cipele)C++11
90 / 90
52 ms3760 KiB
#include <bits/stdc++.h> using namespace std; long long n, m, mini, maxi = 1000000010, medi, l[100000], r[100000]; bool can(long long u){ long long c = 0, p = 0; if(n == m){ for(int i = 0; i < n; i++){ if(abs(l[i]-r[i]) > u) return false; } return true; } else if(n < m){ for(int i = 0; i < m; i++){ if(abs(l[c]-r[i]) <= u){ c++; p++; if(c == n) break; } } if(p == n) return true; return false; } else { for(int i = 0; i < n; i++){ if(abs(r[c]-l[i]) <= u){ c++; p++; if(c == m) break; } } if(p == m) return true; return false; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) cin >> l[i]; for(int i = 0; i < m; i++) cin >> r[i]; sort(l, l+n); sort(r, r+m); while(mini < maxi){ medi = mini+(maxi-mini)/2; if(can(medi)) maxi = medi; else mini = medi+1; } cout << mini; }
#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...