# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170360 |
2019-12-24T21:45:55 Z |
mdn2002 |
Cipele (COCI18_cipele) |
C++14 |
|
61 ms |
1272 KB |
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
int n,m,a[100005],b[100005];
bool ck(int x)
{
if(n>=m)
{
int j=0;
for(int i=0;i<n;i++)
{
int aa=max(a[i],b[j]);
int bb=min(a[i],b[j]);
if((n-i)<(m-j))return 0;
if(aa-bb<=x)j++;
if(j==m)break;
}
if(j==m)return 1;
return 0;
}
else
{
int j=0;
for(int i=0;i<m;i++)
{
int aa=max(a[j],b[i]);
int bb=min(a[j],b[i]);
if((n-j)>(m-i))return 0;
if(aa-bb<=x)j++;
if(j==n)break;
}
if(j==n)return 1;
return 0;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("lemonade.in","r",stdin);
//freopen("lemonade.out","w",stdout);
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<m;i++)cin>>b[i];
sort(a,a+n);
sort(b,b+m);
int l=0,r=1e9+20,mid;
while(l<r)
{
mid=(l+r)/2;
if(ck(mid))r=mid;
else l=mid+1;
}
cout<<l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1272 KB |
Output is correct |
2 |
Correct |
60 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
1144 KB |
Output is correct |
2 |
Correct |
61 ms |
1160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
1016 KB |
Output is correct |
2 |
Correct |
35 ms |
804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
1028 KB |
Output is correct |
2 |
Correct |
36 ms |
936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
1008 KB |
Output is correct |
2 |
Correct |
51 ms |
1076 KB |
Output is correct |