#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 1e5 + 10;
int n, m;
vector<ll> L, R;
bool check(ll x){
int cnt = 0;
for(int i = 0; i < m; i ++){
if(llabs(R[i] - L[cnt]) > x){
continue;
}
cnt ++;
}
return (cnt >= n);
}
int main(int argc, const char * argv[]) {
ios_base::sync_with_stdio(false);
// ifstream cin("in.txt");
cin >> n >> m;
ll num;
for(int i = 0; i < n; i ++){
cin >> num;
L.push_back(num);
}
for(int i = 0; i < m; i ++){
cin >> num;
R.push_back(num);
}
if(n > m){
swap(L, R);
}
n = (int)L.size();
m = (int)R.size();
sort(L.begin(), L.end());
sort(R.begin(), R.end());
ll levo = 0, desno = (1LL << 40LL);
// for(int i = 0; i < n; i ++){
// cout << L[i] << " ";
// }
// cout << endl;
// for(int i =0 ; i < m; i++){
// cout << R[i] << " ";
// }
// cout<<endl;
// cout << check(4) << endl;
ll ret = -1;
while(levo <= desno){
ll mid = levo + ((desno - levo) / 2LL);
if(check(mid)){
desno = mid -1;
ret = mid;
}
else{
levo = mid +1;
}
}
cout << ret << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
4208 KB |
Output is correct |
2 |
Correct |
76 ms |
6016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
7748 KB |
Output is correct |
2 |
Correct |
77 ms |
9588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
9588 KB |
Output is correct |
2 |
Correct |
6 ms |
9588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
9588 KB |
Output is correct |
2 |
Correct |
6 ms |
9588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9588 KB |
Output is correct |
2 |
Correct |
6 ms |
9588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9588 KB |
Output is correct |
2 |
Correct |
6 ms |
9588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9588 KB |
Output is correct |
2 |
Correct |
5 ms |
9588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
9588 KB |
Output is correct |
2 |
Correct |
43 ms |
9588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
9588 KB |
Output is correct |
2 |
Runtime error |
32 ms |
10692 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
12548 KB |
Output is correct |
2 |
Correct |
63 ms |
14216 KB |
Output is correct |