Submission #472219

# Submission time Handle Problem Language Result Execution time Memory
472219 2021-09-13T09:41:39 Z AbdoMo Cipele (COCI18_cipele) C++17
18 / 90
1000 ms 2064 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;
bool comp(pair<int,int>&a ,pair<int,int>&b)
{
    if(a.first==b.first)
    {
        return a.second>b.second;
    }
    return a.first<b.first;

}
void solve()
{
    int n,m;
    cin>>n>>m;
    int arr[100005],arr2[100005];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>arr2[i];
    }
    int ans=0;
    sort(arr,arr+n);
    sort(arr2,arr2+m);

        int tans=0;
        bool vis1[100005]={};
        int c=0;
        for(int i=0;i<n;i++)
        {
            int t=1e13;
            int ind=0;
            for(int j=0;j<m;j++)
            {
                if(vis1[j])continue;
                if(abs(arr[i]-arr2[j])<t)
                {
                    t=abs(arr[i]-arr2[j]);
                    ind = j;
                }

            }
            vis1[ind]=1;
            c++;
            tans=max(tans,t);
            if(c>=min(n,m))
            {
                break;
            }
        }
        c=0;
        bool vis[100005]={};
        for(int i=0;i<m;i++)
        {
           int t=1e13;
            int ind=0;
            for(int j=0;j<n;j++)
            {
                if(vis[j])continue;
                if(abs(arr2[i]-arr[j])<t)
                {
                    t=abs(arr2[i]-arr[j]);
                    ind = j;
                }
            }
            vis[ind]=1;
            ans=max(ans,t);
            if(c>=min(n,m))
            {
                break;
            }
        }
        ans=min(ans,tans);

    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 1062 ms 1996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 1996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 2064 KB Output is correct
2 Correct 57 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1996 KB Output is correct
2 Correct 56 ms 2044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 1996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 1996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 1996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 1996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 1996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 1996 KB Time limit exceeded
2 Halted 0 ms 0 KB -