Submission #83456

# Submission time Handle Problem Language Result Execution time Memory
83456 2018-11-08T01:38:39 Z charlies_moo Cipele (COCI18_cipele) C++17
90 / 90
62 ms 11280 KB
#include <cstdio>
#include <algorithm>

using namespace std;

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

    if (n > m) {
        swap(n, m);
        swap(a, b);
    }

    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 && b[j] < a[i] - mi) {
                j++;
            }
            if (j == m || b[j] > a[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 37 ms 2680 KB Output is correct
2 Correct 58 ms 4560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 6340 KB Output is correct
2 Correct 62 ms 7748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7748 KB Output is correct
2 Correct 4 ms 7748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7748 KB Output is correct
2 Correct 5 ms 7748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 7748 KB Output is correct
2 Correct 4 ms 7748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7748 KB Output is correct
2 Correct 5 ms 7748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7748 KB Output is correct
2 Correct 4 ms 7748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 7772 KB Output is correct
2 Correct 35 ms 7772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 7900 KB Output is correct
2 Correct 28 ms 8284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 9668 KB Output is correct
2 Correct 54 ms 11280 KB Output is correct