# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
855729 |
2023-10-01T17:21:47 Z |
vjudge1 |
Cipele (COCI18_cipele) |
C++17 |
|
34 ms |
1248 KB |
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define ONLINE_JUDGE
void solve() {
int n, m;
cin >> n >> m;
vector <int> a(n +1), b(m +1);
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int j = 1; j <= m; j++)
cin >> b[j];
if(n > m) {
swap(a, b);
swap(n, m);
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
auto check = [&](int c) -> bool {
int ind = 1;
//cerr << c << ": \n";
for(int i = 1; i <= n; i++) {
while(ind <= m && abs(a[i] - b[ind]) > c)
ind++;
if(ind == m +1) {
return false;
}
//cerr << a[i] << " " << b[ind] << "\n";
ind++;
}
return true;
};
int l = 0, r = 1E9, ans = 0;
while(l <= r) {
int mid = (l + r) / 2;
if(check(mid)) {
ans = mid;
r = mid -1;
} else {
l = mid +1;
}
cerr << "\n";
}
cout << ans << "\n";
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1116 KB |
Output is correct |
2 |
Correct |
30 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1248 KB |
Output is correct |
2 |
Correct |
34 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
860 KB |
Output is correct |
2 |
Correct |
18 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1116 KB |
Output is correct |
2 |
Correct |
18 ms |
1052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1084 KB |
Output is correct |
2 |
Correct |
30 ms |
1116 KB |
Output is correct |