# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
894389 |
2023-12-28T08:23:53 Z |
vjudge1 |
Cipele (COCI18_cipele) |
C++17 |
|
31 ms |
1196 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ppb pop_back()
const int N = (int)1e5 + 5;
const ll mod = (int)1e9 + 7;
const ll inf = (1e9) + 100;
int n, m;
int a[N], b[N];
bool ok(int k) {
int j = 1;
for (int i = 1; i <= min(n, m); i++) {
if (n <= m) {
while (j <= m && abs(a[i] - b[j]) > k) j++;
if (j > m) return 0;
j++;
} else {
while (j <= n && abs(a[j] - b[i]) > k) j++;
if (j > n) return 0;
j++;
}
}
return 1;
}
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= m; i++) {
cin >> b[i];
}
sort(a + 1, a + n + 1);
sort(b + 1, b + 1 + m);
int l = 0, r = inf, ans = inf;
while (l <= r) {
int mid = (l + r) / 2;
if (ok(mid)) {
r = mid - 1;
ans = mid;
} else l = mid + 1;
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int T = 1;
//cin >> T;
while (T--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1116 KB |
Output is correct |
2 |
Correct |
30 ms |
1196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1112 KB |
Output is correct |
2 |
Correct |
30 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 |
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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1116 KB |
Output is correct |
2 |
Correct |
20 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1112 KB |
Output is correct |
2 |
Correct |
14 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
860 KB |
Output is correct |
2 |
Correct |
29 ms |
1116 KB |
Output is correct |