# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
115463 |
2019-06-07T15:34:00 Z |
Vlatko |
Cipele (COCI18_cipele) |
C++14 |
|
733 ms |
12536 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int n, m;
map<int, pii> counts;
vector<int> A, B;
multiset<int> Bset;
bool possible(int limit) {
multiset<int> s = Bset;
for (int x : A) {
// y <= x
auto it = s.lower_bound(x - limit);
if (it != s.end() && *it <= x) {
s.erase(it);
} else {
// y > x
it = s.lower_bound(x+1);
if (it == s.end() || *it > x+limit) {
return false;
}
s.erase(it);
}
}
return true;
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
A.resize(n);
B.resize(m);
for (int i = 0; i < n; ++i) {
cin >> A[i];
}
for (int i = 0; i < m; ++i) {
cin >> B[i];
}
if (n > m) {
swap(n, m);
swap(A, B);
}
sort(A.begin(), A.end());
for (int i = 0; i < m; ++i) {
Bset.insert(B[i]);
}
int lo = 0, hi = 1e9, mid, ans = 1e9;
while (lo <= hi) {
mid = (lo + hi) / 2;
if (possible(mid)) {
ans = mid;
hi = mid-1;
} else {
lo = mid+1;
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
419 ms |
12160 KB |
Output is correct |
2 |
Correct |
594 ms |
12428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
668 ms |
12380 KB |
Output is correct |
2 |
Correct |
605 ms |
12536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
640 KB |
Output is correct |
2 |
Correct |
18 ms |
996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
896 KB |
Output is correct |
2 |
Correct |
18 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
896 KB |
Output is correct |
2 |
Correct |
16 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
896 KB |
Output is correct |
2 |
Correct |
17 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
896 KB |
Output is correct |
2 |
Correct |
18 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
733 ms |
11544 KB |
Output is correct |
2 |
Correct |
330 ms |
7488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
619 ms |
11512 KB |
Output is correct |
2 |
Correct |
289 ms |
10332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
602 ms |
11000 KB |
Output is correct |
2 |
Correct |
538 ms |
10716 KB |
Output is correct |