Submission #779363

#TimeUsernameProblemLanguageResultExecution timeMemory
779363b00norpCipele (COCI18_cipele)C++14
0 / 90
26 ms3668 KiB
#include <bits/stdc++.h> using namespace std; #define int long long mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); const int INF = 1e18; void Solve() { int n, m; cin >> n >> m; vector<int> a(n + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; } vector<int> b(m + 1); for(int i = 1; i <= m; i++) { cin >> b[i]; } if(n > m) { swap(n, m); swap(a, b); } int l = 0, r = 1e9, ans = r; while(l <= r) { int mid = (l + r) / 2; int b_pos = 1, covered = 0; for(int i = 1; i <= n; i++) { while(b_pos != m + 1 && abs(a[i] - b[b_pos]) > mid) { b_pos += 1; if(b_pos == m + 1) { break; } } if(b_pos != m + 1) { b_pos += 1; covered += 1; } } if(covered == n) { ans = mid; r = mid - 1; } else { l = mid + 1; } } cout << ans << "\n"; } int32_t main() { auto begin = std::chrono::high_resolution_clock::now(); ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; for(int i = 1; i <= t; i++) { //cout << "Case #" << i << ": "; Solve(); } auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin); //cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\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...