# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
779179 |
2023-07-11T08:42:52 Z |
vjudge1 |
Cipele (COCI18_cipele) |
C++17 |
|
33 ms |
1104 KB |
//#include<bits/stdc++.h>
#include<iostream>
#include<bitset>
#include<algorithm>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define pb push_back
#define N 100005
bitset<N> var;
int main(){
lalala;
int n,m;cin>>n>>m;
int sa[n],sol[m];
for(int i=0;i<n;i++)cin>>sa[i];
for(int i=0;i<m;i++)cin>>sol[i];
sort(sa,sa+n);
sort(sol,sol+m);
if(n==m){
int mx=0;
for(int i=0;i<n;i++)mx=max(mx,abs(sa[i]-sol[i]));
cout<<mx<<endl;
return 0;
}
if(n<m){
int mx=0;
for(int i=n-1;i>-1;i--){
int l=0,r=m-1;
while(l<r){
int mid=(l+r)/2;
//cout<<l<<" "<<r<<" "<<mid<<" "<<sol[mid]<<" "<<sa[i]<<endl;
if(sol[mid]>=sa[i]){
r=mid;
}
else l=mid+1;
}
int a=l,b=l;
if(l!=0)a--;
if(var[a]&&a>i){
a--;
}
while(var[b]&&b!=m-1){
b++;
}
//cout<<a<<" "<<b<<endl;
if(var[a]||abs(sol[b]-sa[i])<abs(sol[a]-sa[i])){
mx=max(mx,abs(sol[b]-sa[i]));
var[b]=1;
}
else{
mx=max(mx,abs(sol[a]-sa[i]));
var[a]=1;
}
}
cout<<mx<<endl;
}
else{
int mx=0;
for(int i=m-1;i>-1;i--){
int l=0,r=n-1;
while(l<r){
int mid=(l+r)/2;
if(sa[mid]>sol[i]){
r=mid;
}
else l=mid+1;
}
int a=l,b=l;
if(l!=0)a--;
if(var[a]&&a>i){
a--;
}
while(var[b]&&b!=n-1){
b++;
}
//cout<<i<<" "<<a<<" "<<b<<endl;
if(var[a]||abs(sa[b]-sol[i])<abs(sa[a]-sol[i])){
mx=max(mx,abs(sa[b]-sol[i]));
var[b]=1;
}
else{
mx=max(mx,abs(sa[a]-sol[i]));
var[a]=1;
}
}
cout<<mx<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1104 KB |
Output is correct |
2 |
Correct |
28 ms |
1096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1096 KB |
Output is correct |
2 |
Correct |
28 ms |
1084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
13 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
16 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
852 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
1016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |