Submission #242450

# Submission time Handle Problem Language Result Execution time Memory
242450 2020-06-27T17:37:22 Z JovanK26 Cipele (COCI18_cipele) C++14
90 / 90
55 ms 2956 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(m);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<m;i++)
    {
        cin >> b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n>m)
    {
        swap(n,m);
        swap(a,b);
    }
    int l=0;
    int r=1000000000;
    int mid;
    bool check;
    while(l<r)
    {
        mid=(l+r)/2;
        int j=0;
        check=0;
        for(int i=0;i<n;i++)
        {
            while(j<m && abs(a[i]-b[j])>mid)j++;
            if(j==m)
            {
                check=1;
                break;
            }
            j++;
        }
        if(!check)
        {
            r=mid;
        }
        else
        {
            l=mid+1;
        }
    }
    cout << l;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2680 KB Output is correct
2 Correct 54 ms 2956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 2944 KB Output is correct
2 Correct 54 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 640 KB Output is correct
2 Correct 10 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2432 KB Output is correct
2 Correct 33 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 2680 KB Output is correct
2 Correct 31 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2424 KB Output is correct
2 Correct 46 ms 2560 KB Output is correct