Submission #742694

#TimeUsernameProblemLanguageResultExecution timeMemory
742694IDorandoCipele (COCI18_cipele)C++17
90 / 90
47 ms2768 KiB
#include <bits/stdc++.h> using namespace std; int n, m, l[100005], r[100005]; bool Check(int x) { int i, j; i = j = 0; while (i <= n and j <= m) { if (l[i] <= r[j]) { if (r[j] - l[i] <= x) { i++; j++; } else return 0; } else { if (l[i] - r[j] <= x) { i++; j++; } else j++; } } return (i == n + 1); } int main() { int i, st, dr, mij, sol, ma = 0; ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; if (m < n) { swap(m, n); for (i = 1; i <= m; i++) { cin >> r[i]; ma = max(ma, r[i]); } for (i = 1; i <= n; i++) { cin >> l[i]; ma = max(ma, l[i]); } } else { for (i = 1; i <= n; i++) { cin >> l[i]; ma = max(ma, l[i]); } for (i = 1; i <= m; i++) { cin >> r[i]; ma = max(ma, r[i]); } } sort(l + 1, l + n + 1); sort(r + 1, r + m + 1); st = sol = 0; dr = ma; while (st <= dr) { mij = (st + dr) / 2; if (Check(mij) == 1) { sol = mij; dr = mij - 1; } else st = mij + 1; } cout << sol << "\n"; 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...