#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define read freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define LESSGO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N=1e6+10,M=505,OO=1e16,mod=1e9+7;
int n,m;
vector<ll>a,b;
bool ok(ll bound){
int l=0;
for(int i=0;i<n;++i){
int idx=lower_bound(b.begin()+l,b.end(),a[i]-bound)-b.begin();
cout<<idx<<"\n";
if(b[idx]>a[i]){
if(b[idx]-a[i]>bound) return 0;
}
l=idx+1;
}
return 1;
}
ll bs(){
ll low=0,high=1e12,med;
while(low<high){
med=(low+high)>>1;
if(ok(med)) high=med;
else low=med+1;
}
return low;
}
int main(){
cin>>n>>m;
for(int i=0;i<n;++i){
ll x; cin>>x;
a.push_back(x);
}
for(int i=0;i<m;++i){
ll x; cin>>x;
b.push_back(x);
}
if(n>m){
swap(a,b);
swap(n,m);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
cout<<bs()<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
639 ms |
25016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
652 ms |
26892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
460 ms |
18316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
581 ms |
22928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
456 ms |
18560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |