# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
145286 |
2019-08-19T13:40:06 Z |
Fasho |
Cipele (COCI18_cipele) |
C++14 |
|
144 ms |
3844 KB |
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.in","r",stdin);freopen ("kmp.out","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;
ll n,m,ar[N],sum,b[N];
ll get(int l,int x)
{
int r=m;
while(l<r)
{
if(l==r-1)
{
if(b[l]>=x)
r=l;
break;
}
int mid=(l+r)/2;
if(b[mid]>=x)
r=mid;
else
l=mid+1;
}
return r;
}
bool check(int x)
{
int l=1;
for(int i=1;i<=n;i++)
{
ll y=get(l,ar[i]-x);
if(y>m || fabs(b[y]-ar[i])>x)
return 0;
l=y+1;
}
return 1;
}
int main()
{
fast;
cin>>n>>m;
fs(ar,n);
fs(b,m);
sort(ar+1,ar+n+1);
sort(b+1,b+m+1);
if(m<n)
{
fo(i,1,n)
swap(ar[i],b[i]);
swap(n,m);
}
if(n==m)
{
fo(i,1,n)
sum=max(sum,abs(ar[i]-b[i]));
return cout<<sum,0;
}
ll l=0,r=max(ar[n],b[m])-min(ar[1],b[1]);
while(l<r)
{
if(l==r-1)
{
if(check(l))
r=l;
break;
}
int mid=(l+r)/2;
if(check(mid))
r=mid;
else
l=mid+1;
}
// cout<<endl;
cout<<r<<endl;
// cout<<endl;
// cout<<endl;
// fo(i,1,n)
// cout<<ar[i]<<sp;
// cout<<endl;
// fo(i,1,m)
// cout<<b[i]<<sp;
// cout<<endl;
// cout<<endl<<check(1)<<endl;
}
/* cd onedrive\desktop\kod
cls
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
3576 KB |
Output is correct |
2 |
Correct |
47 ms |
3704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
3704 KB |
Output is correct |
2 |
Correct |
49 ms |
3844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
8 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
8 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
3064 KB |
Output is correct |
2 |
Correct |
94 ms |
2360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
3384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
3036 KB |
Output is correct |
2 |
Incorrect |
144 ms |
3252 KB |
Output isn't correct |