Submission #472337

# Submission time Handle Problem Language Result Execution time Memory
472337 2021-09-13T11:57:20 Z MamdouhN Cipele (COCI18_cipele) C++14
9 / 90
1000 ms 15796 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

vector<int>lol,L,R;
map<int,int>reps;
main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        lol.push_back(x);
        reps[x]++;
    }
    for(int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        if(reps[x]==0)
            R.push_back(x);
        else reps[x] = -1;
    }
    for(int i=0;i<n;i++)
    {
        if(reps[lol[i]]!=-1)L.push_back(lol[i]);
    }

    sort(L.begin(),L.end());
    sort(R.begin(),R.end());
    //for(auto v:L)cout<<v<<" ";
    //cout<<endl;for(auto v:R)cout<<v<<" ";
    //cout<<endl;
    n=L.size();
    m=R.size();
    if(n>m)
    {
        swap(n,m);
        swap(L,R);
    }
    int st=0,en=n-1;
    int answer = 1e9;
    while(en<=m-1)
    {
        int ans=0;
        int j=st;
        for(int i=0;i<n;i++)
        {
            int x = abs(L[i]-R[j]);
            ans=max(ans,x);
            j++;
        }
        answer = min(answer,ans);
        st++;
        en++;
    }
    cout<<answer<<endl;
}

Compilation message

cipele.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 132 ms 15672 KB Output is correct
2 Incorrect 305 ms 15736 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 278 ms 15796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 9 ms 1100 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 12 ms 888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 12532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 14240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 12816 KB Time limit exceeded
2 Halted 0 ms 0 KB -