# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472361 |
2021-09-13T12:21:25 Z |
AbdoMo |
Cipele (COCI18_cipele) |
C++17 |
|
1000 ms |
5316 KB |
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
const int mod = 1e9+7;
using namespace std;
void solve(){
int n,m;
cin>>n>>m;
vector<int>v1,v2;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
v1.pb(x);
}
for(int i=0;i<m;i++)
{
int x;
cin>>x;
v2.pb(x);
}
int arr[n+m],arr2[n+m];
if(n>m)
{
for(int i=0;i<n;i++)
{
arr2[i]=v1[i];
}
for(int i=0;i<m;i++)
{
arr[i]=v2[i];
}
swap(n,m);
}
else
{
for(int i=0;i<n;i++)
{
arr[i]=v1[i];
}
for(int i=0;i<m;i++)
{
arr2[i]=v2[i];
}
}
sort(arr,arr+n);
sort(arr2,arr2+m);
bool vis[n+m+100]={};
int ans=1e13;
int ta=0;
for(int i=0;i<n;i++)
{
int mni=0,mn=1e13;
for(int j=0;j<m;j++)
{
if(!vis[j])
{
if(abs(arr[i]-arr2[j])<mn)
{
mn=abs(arr[i]-arr2[j]);
mni=j;
}
}
}
vis[mni]=1;
ta=max(ta,mn);
}
ans=min(ans,ta);
bool vis2[n+m+100]={};
ta=0;
reverse(arr,arr+n);
reverse(arr2,arr2+m);
// cout<<endl;
for(int i=0;i<n;i++)
{
//cout<<arr[i]<<" ";
int mni=0,mn=1e13;
for(int j=0;j<m;j++)
{
//cout<<arr2[j]<<" ";
if(!vis2[j])
{
if(abs(arr[i]-arr2[j])<mn)
{
mn=abs(arr[i]-arr2[j]);
mni=j;
}
}
}
vis2[mni]=1;
ta=max(ta,mn);
}
ans=min(ans,ta);
cout<<ans<<endl;
}
int32_t main(){
int t=1;
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//cin>>t;
while(t--){solve();}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
5316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
5248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
480 KB |
Output is correct |
2 |
Correct |
57 ms |
612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
512 KB |
Output is correct |
2 |
Correct |
64 ms |
612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
72 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
82 ms |
568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
78 ms |
612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
4400 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
4768 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
4324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |