Submission #83354

# Submission time Handle Problem Language Result Execution time Memory
83354 2018-11-07T09:34:52 Z charlies_moo Cipele (COCI18_cipele) C++17
90 / 90
97 ms 11196 KB
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int a[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int b[m];
    for (int i = 0; i < m; i++) {
        scanf("%d", &b[i]);
    }
    sort(a, a+n);
    sort(b, b+m);

    int *p, *q;
    if (n < m) {
        p = a;
        q = b;
    } else {
        swap(n, m);
        p = b;
        q = a;
    }

    int l = -1, r = 1e9+1;
    while (r - l > 1) {
        int mi = (l + r) / 2;

        bool flag = true;
        int j = 0;
        for (int i = 0; i < n; i++) {
            while (j < m && q[j] < p[i] - mi) {
                j++;
            }
            if (j == m || q[j] > p[i] + mi) {
                flag = false;
                break;
            }
            j++;
        }

        if (flag) {
            r = mi;
        } else {
            l = mi;
        }
    }

    printf("%d\n", r);

    return 0;
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
cipele.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
cipele.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &b[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2552 KB Output is correct
2 Correct 80 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 6304 KB Output is correct
2 Correct 97 ms 7876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7876 KB Output is correct
2 Correct 5 ms 7876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7876 KB Output is correct
2 Correct 4 ms 7876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7876 KB Output is correct
2 Correct 4 ms 7876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7876 KB Output is correct
2 Correct 4 ms 7876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7876 KB Output is correct
2 Correct 4 ms 7876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 7876 KB Output is correct
2 Correct 35 ms 7876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 7924 KB Output is correct
2 Correct 27 ms 8160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 9732 KB Output is correct
2 Correct 60 ms 11196 KB Output is correct