# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472382 |
2021-09-13T12:42:19 Z |
AbdoMo |
Cipele (COCI18_cipele) |
C++17 |
|
1000 ms |
5264 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);
vector<pair<int,int>>dif;
for(int i=0;i<m;i++)
{
dif.pb({0,i});
for(int j=0;j<n;j++)
{
dif[i].first=max(dif[i].first,abs(arr[j]-arr2[i]));
}
}
bool vis[n+m+100]={};
bool vis2[n+m+100]={};
sort(dif.rbegin(),dif.rend());
for(int i=0;i<abs(n-m);i++)
{
vis[dif[i].second]=1;
vis2[dif[i].second]=1;
}
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);
ta=0;
reverse(arr,arr+n);
reverse(arr2,arr2+m);
reverse(vis,vis+m);
reverse(vis2,vis2+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 |
1079 ms |
5264 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
5140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
556 KB |
Output is correct |
2 |
Correct |
101 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
736 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
97 ms |
652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
4616 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
4844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
4560 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |