Submission #472362

# Submission time Handle Problem Language Result Execution time Memory
472362 2021-09-13T12:22:29 Z AbdoMo Cipele (COCI18_cipele) C++11
18 / 90
1000 ms 5280 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 1083 ms 5280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 5208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 480 KB Output is correct
2 Correct 60 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 60 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 4384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 4676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 4256 KB Time limit exceeded
2 Halted 0 ms 0 KB -