#include <bits/stdc++.h>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
ll n,m;
ll arr[1000001];
ll arr1[1000001];
void solve(){
cin>>n>>m;
if(n>m){
for(int i=1;i<=n;i++) cin>>arr1[i];
for(int i=1;i<=m;i++) cin>>arr[i];
swap(n,m);
}
else{
for(int i=1;i<=n;i++) cin>>arr[i];
for(int i=1;i<=m;i++) cin>>arr1[i];
}
sort(arr,arr+n);
sort(arr1,arr1+m);
ll l,r;
l=0,r=1e9;
while(l<=r){
ll mid=(l+r)/2;
ll l1,r1;
l1=0,r1=0;
while(l1<n&&r1<m){
if(arr[l1]-arr1[r1]<=mid) l1++,r1++;
else r1++;
}
if(l1==n) r=mid-1;
else l=mid+1;
}
co r+1;
}
int main()
{
suiii
int tt=1;
// cin>>tt;
while(tt--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
2908 KB |
Output is correct |
2 |
Incorrect |
35 ms |
4688 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
3164 KB |
Output is correct |
2 |
Incorrect |
36 ms |
3152 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
2652 KB |
Output is correct |
2 |
Incorrect |
20 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
2864 KB |
Output is correct |
2 |
Incorrect |
20 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
4116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |