Submission #672887

#TimeUsernameProblemLanguageResultExecution timeMemory
672887andrei_c1Cipele (COCI18_cipele)C++14
90 / 90
46 ms2384 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL ifstream fin("input.txt"); ofstream fout("output.txt"); #else #define fin cin #define fout cout #endif const int INF = 0x3f3f3f3f; const int LIM = 1e9; int tc, testCases = 1; int N, M; vector<int> L, R; bool check(int diff) { int i = 0, j = 0; while(i < N && j < M) { if(abs(L[i] - R[j]) <= diff) { i++; } j++; } return i == N; } void solve() { fin >> N >> M; L = vector<int> (N); R = vector<int> (M); for(int &it: L) { fin >> it; } for(int &it: R) { fin >> it; } if(N > M) { swap(N, M); L.swap(R); } sort(L.begin(), L.end()); sort(R.begin(), R.end()); int st = 0, dr = LIM, mid, ans = -1; while(st <= dr) { mid = (st + dr) >> 1; if(check(mid)) { ans = mid; dr = mid - 1; } else { st = mid + 1; } } fout << ans << '\n'; } signed main() { ios_base :: sync_with_stdio(false); fin.tie(0); fout.tie(0); // fin >> testCases; for(tc = 0; tc < testCases; tc++) { solve(); } 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...