# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
702147 |
2023-02-23T06:00:25 Z |
chenyan |
Cipele (COCI18_cipele) |
C++17 |
|
42 ms |
3604 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define N 100010
int n,m,a[N],b[N],ans=1e9;
bool f(int x){
for(int i=0,j=0;i<n;i++,j++){
while(j<m&&abs(a[i]-b[j])>x)j++;
if(j==m)return 0;
}
ans=min(ans,x);
return 1;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int i,j,k;
cin>>n>>m;
for(i=0;i<n;i++)cin>>a[i];
for(i=0;i<m;i++)cin>>b[i];
if(n>m)swap(n,m),swap(a,b);
sort(a,a+n),sort(b,b+m);
for(i=1e9,j=0;i;i>>=1){
while(i+j<1e9&&!f(i+j))j+=i;
}
f(0);
cout<<ans<<'\n';
}
Compilation message
cipele.cpp: In function 'int main()':
cipele.cpp:22:10: warning: unused variable 'k' [-Wunused-variable]
22 | int i,j,k;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
2020 KB |
Output is correct |
2 |
Correct |
36 ms |
3604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
2152 KB |
Output is correct |
2 |
Correct |
38 ms |
3580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
1764 KB |
Output is correct |
2 |
Correct |
31 ms |
2836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1892 KB |
Output is correct |
2 |
Correct |
20 ms |
2988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1664 KB |
Output is correct |
2 |
Correct |
33 ms |
3276 KB |
Output is correct |