# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
779369 |
2023-07-11T11:14:13 Z |
b00norp |
Cipele (COCI18_cipele) |
C++14 |
|
39 ms |
3528 KB |
#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);
}
sort(a.begin() + 1, a.end());
sort(b.begin() + 1, b.end());
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 time |
Memory |
Grader output |
1 |
Correct |
21 ms |
2312 KB |
Output is correct |
2 |
Correct |
39 ms |
2276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
2400 KB |
Output is correct |
2 |
Correct |
35 ms |
3528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
368 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
400 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
448 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
2020 KB |
Output is correct |
2 |
Correct |
20 ms |
2252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
2292 KB |
Output is correct |
2 |
Correct |
14 ms |
2544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1868 KB |
Output is correct |
2 |
Correct |
31 ms |
3168 KB |
Output is correct |