# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
819326 |
2023-08-10T09:27:37 Z |
vjudge1 |
Cipele (COCI18_cipele) |
C++17 |
|
124 ms |
11116 KB |
#include<bits/stdc++.h>
#include<math.h>
#define _USE_MATH_DEFINES
using namespace std;
/**struct node
{
long long idx;
long long dis;
node(){}
node(long long _idx,long long _dis)
{
idx=_idx;
dis=_dis;
}
bool operator<(const node &tmp)const{
return dis>tmp.dis;
}
};**/
const long long maxn=1e5+10;
const long long mod=1e9+7;
int main()
{
long long n,m;
cin>>n>>m;
long long L[n];
long long R[m];
map<int,int>pl;
map<int,int>pr;
for(long long i=0;i<n;i++)
{
cin>>L[i];
pl[L[i]]++;
}
for(long long j=0;j<m;j++)
{
cin>>R[j];
pr[R[j]]++;
}
sort(L,L+n);
sort(R,R+m);
if(n==m)
{
long long mx=0;
for(long long i=0;i<n;i++)
{
mx=max(mx, abs(L[i]-R[i]));
}
cout<<mx<<endl;
}
else
{
if(n<m)
{
long long j=-1;
long long ans=0;
for(long long i=0;i<n;i++)
{
long long raz=2e9;
while(j+1<m-(n-i-1) && abs(L[i]-R[j+1])<=raz)
{
raz=abs(L[i]-R[j+1]);
j++;
if(pl[L[i]]>1)
{
break;
}
}
///cout<<j<<" ";
ans=max(ans, raz);
}
cout<<ans<<endl;
}
else
{
long long j=-1;
long long ans=0;
for(long long i=0;i<m;i++)
{
long long raz=2e9;
while(j+1<n-(m-i-1) && abs(L[j+1]-R[i])<=raz)
{
raz=abs(L[j+1]-R[i]);
j++;
if(pr[R[i]]>1)
{
break;
}
}
ans=max(ans, raz);
}
cout<<ans<<endl;
}
}
return 0;
}
/*5 5
7 6 1 2 10
9 11 6 3 12
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
11116 KB |
Output is correct |
2 |
Correct |
119 ms |
11080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
11084 KB |
Output is correct |
2 |
Correct |
121 ms |
11096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Incorrect |
7 ms |
752 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Incorrect |
6 ms |
724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
103 ms |
9080 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
124 ms |
9964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
124 ms |
8980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |