Submission #165688

# Submission time Handle Problem Language Result Execution time Memory
165688 2019-11-28T09:22:42 Z handlename Cipele (COCI18_cipele) C++17
90 / 90
56 ms 3068 KB
#include <bits/stdc++.h>
using namespace std;
int n,m;
int arr[100001];
int brr[100001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for (int i=0;i<n;i++) cin>>arr[i];
    for (int i=0;i<m;i++) cin>>brr[i];
    sort(arr,arr+n);
    sort(brr,brr+m);
    int mini=-1,maxi=1000000000;
    while (mini+1<maxi){
        int middle=(mini+maxi)/2;
        int apos=0,bpos=0,taken=0;
        while (apos<n && bpos<m){
            if (abs(arr[apos]-brr[bpos])<=middle){
                apos++;
                bpos++;
                taken++;
            }
            else if (arr[apos]<brr[bpos]) apos++;
            else bpos++;
        }
        if (taken==min(m,n)) maxi=middle;
        else mini=middle;
    }
    cout<<maxi;
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2680 KB Output is correct
2 Correct 53 ms 2940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 3068 KB Output is correct
2 Correct 54 ms 2984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 404 KB Output is correct
2 Correct 4 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2396 KB Output is correct
2 Correct 33 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 2552 KB Output is correct
2 Correct 26 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 2420 KB Output is correct
2 Correct 49 ms 2544 KB Output is correct