// This code is written by _L__
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7, N = 1e5+300, INF = 1e18;
const ld E = 1e-6;
int main(void){
F_word;
int n, m; cin >> n >> m;
vector<ll> l(n), r(m); for(int i = 0; i < n; ++i) cin >> l[i]; for(int i =0 ; i < m; ++i) cin >> r[i];
sort(l.begin(), l.end());
sort(r.begin(), r.end());
if(n <= m){
ll ans = 0;
for(int i = 0; i < n; ++i){
ll idx = 0, b = INT_MAX;
for(int j = 0; j < r.size(); ++j){
if(abs(r[j]-l[i]) <= b){
b = abs(r[j]-l[i]);
idx = j;
}
}
r.erase(r.begin()+idx);
ans = max(ans, b);
}
cout << ans << endl;
} else {
ll ans = 0;
for(int i = 0; i < m; ++i){
ll idx = 0, b = INT_MAX;
for(int j =0;j < l.size(); ++j){
if(abs(l[j]-r[i]) <= b){
idx = j;
b = abs(r[i]-l[j]);
}
}
l.erase(l.begin()+idx);
ans = max(ans, b);
}
cout << ans << endl;
}
}
Compilation message
cipele.cpp: In function 'int main()':
cipele.cpp:25:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(int j = 0; j < r.size(); ++j){
| ~~^~~~~~~~~~
cipele.cpp:39:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int j =0;j < l.size(); ++j){
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
1868 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1080 ms |
1868 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
332 KB |
Output is correct |
2 |
Correct |
20 ms |
388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
20 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1084 ms |
1484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1088 ms |
1612 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
1484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |