# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170328 |
2019-12-24T20:05:01 Z |
ngmh |
Cipele (COCI18_cipele) |
C++11 |
|
52 ms |
3760 KB |
#include <bits/stdc++.h>
using namespace std;
long long n, m, mini, maxi = 1000000010, medi, l[100000], r[100000];
bool can(long long u){
long long c = 0, p = 0;
if(n == m){
for(int i = 0; i < n; i++){
if(abs(l[i]-r[i]) > u) return false;
}
return true;
} else if(n < m){
for(int i = 0; i < m; i++){
if(abs(l[c]-r[i]) <= u){
c++;
p++;
if(c == n) break;
}
}
if(p == n) return true;
return false;
} else {
for(int i = 0; i < n; i++){
if(abs(r[c]-l[i]) <= u){
c++;
p++;
if(c == m) break;
}
}
if(p == m) return true;
return false;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> l[i];
for(int i = 0; i < m; i++) cin >> r[i];
sort(l, l+n);
sort(r, r+m);
while(mini < maxi){
medi = mini+(maxi-mini)/2;
if(can(medi)) maxi = medi;
else mini = medi+1;
}
cout << mini;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
3448 KB |
Output is correct |
2 |
Correct |
49 ms |
3704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
3704 KB |
Output is correct |
2 |
Correct |
52 ms |
3760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
504 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
504 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
3108 KB |
Output is correct |
2 |
Correct |
31 ms |
2364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
3424 KB |
Output is correct |
2 |
Correct |
25 ms |
2608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
3064 KB |
Output is correct |
2 |
Correct |
43 ms |
3164 KB |
Output is correct |