# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
159693 |
2019-10-24T01:23:12 Z |
socho |
Cipele (COCI18_cipele) |
C++14 |
|
187 ms |
3124 KB |
#include "bits/stdc++.h"
using namespace std;
long long n, m;
const long long MXN = 100005;
long long a1[MXN], a2[MXN];
bool works(long long x) {
long long lpt = 0;
long long rpt = 0;
for (long long i=0; i<n; i++) {
long long at = a1[i];
long long mxr = at + x;
long long mnr = at - x;
while (rpt < m && a2[rpt] <= mxr) {
rpt++;
}
while (lpt < m && a2[lpt] < mnr) {
lpt++;
}
if (lpt == rpt) {
return false;
}
lpt++;
}
return true;
}
int main() {
cin >> n >> m;
if (n < m) {
for (long long i=0; i<n; i++) {
cin >> a1[i];
}
for (long long i=0; i<m; i++) {
cin >> a2[i];
}
}
else {
for (long long i=0; i<n; i++) {
cin >> a2[i];
}
for (long long i=0; i<m; i++) {
cin >> a1[i];
}
swap(n, m);
}
sort(a1, a1+n); sort(a2, a2+m);
long long low = 0;
long long high = INT_MAX;
while (low + 1 < high) {
long long mid = (low + high) / 2;
bool res = works(mid);
if (res) {
high = mid;
}
else {
low = mid;
}
}
if (works(low)) {
cout << low << endl;
}
else {
cout << high << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
1912 KB |
Output is correct |
2 |
Correct |
187 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
187 ms |
2040 KB |
Output is correct |
2 |
Correct |
186 ms |
1924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
159 ms |
1656 KB |
Output is correct |
2 |
Correct |
110 ms |
2332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
1752 KB |
Output is correct |
2 |
Correct |
107 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
1572 KB |
Output is correct |
2 |
Correct |
161 ms |
3124 KB |
Output is correct |