Submission #896528

#TimeUsernameProblemLanguageResultExecution timeMemory
896528vjudge1Cipele (COCI18_cipele)C++17
90 / 90
34 ms3040 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; using ll = long long; const int maxN = 1e5 + 1; int a[maxN], b[maxN], m, n; void ReadInput() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> b[i]; if (n > m) { swap(m, n); swap(a, b); } sort(a + 1, a + n + 1); sort(b + 1, b + m + 1); } bool check(int x) { int j = 1; for (int i = 1; i <= n; i++) { //cout << a[i] << ' '; while (j <= m && abs(b[j] - a[i]) > x) j++; // cout << b[j] << ' '; //cout << '\n'; if (j == m + 1) return false; j++; } return true; } void Solve() { int l = 0, r = 1e9; while (l <= r) { int mid = (l + r) / 2; if (check(mid)) r = mid - 1; else l = mid + 1; } cout << l; } #define task "" int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen(task".INP", "r", stdin); //freopen(task".OUT", "w", stdout); int T = 1; //cin >> T; while (T--) { ReadInput(); Solve(); } }
#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...