# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
742694 |
2023-05-16T18:09:02 Z |
IDorando |
Cipele (COCI18_cipele) |
C++17 |
|
47 ms |
2768 KB |
#include <bits/stdc++.h>
using namespace std;
int n, m, l[100005], r[100005];
bool Check(int x)
{
int i, j;
i = j = 0;
while (i <= n and j <= m)
{
if (l[i] <= r[j])
{
if (r[j] - l[i] <= x)
{
i++;
j++;
}
else
return 0;
}
else
{
if (l[i] - r[j] <= x)
{
i++;
j++;
}
else j++;
}
}
return (i == n + 1);
}
int main()
{
int i, st, dr, mij, sol, ma = 0;
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
if (m < n)
{
swap(m, n);
for (i = 1; i <= m; i++)
{
cin >> r[i];
ma = max(ma, r[i]);
}
for (i = 1; i <= n; i++)
{
cin >> l[i];
ma = max(ma, l[i]);
}
}
else
{
for (i = 1; i <= n; i++)
{
cin >> l[i];
ma = max(ma, l[i]);
}
for (i = 1; i <= m; i++)
{
cin >> r[i];
ma = max(ma, r[i]);
}
}
sort(l + 1, l + n + 1);
sort(r + 1, r + m + 1);
st = sol = 0;
dr = ma;
while (st <= dr)
{
mij = (st + dr) / 2;
if (Check(mij) == 1)
{
sol = mij;
dr = mij - 1;
}
else st = mij + 1;
}
cout << sol << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
2516 KB |
Output is correct |
2 |
Correct |
43 ms |
2768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
2708 KB |
Output is correct |
2 |
Correct |
44 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2448 KB |
Output is correct |
2 |
Correct |
25 ms |
1772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
2536 KB |
Output is correct |
2 |
Correct |
21 ms |
2004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
2268 KB |
Output is correct |
2 |
Correct |
41 ms |
2500 KB |
Output is correct |