답안 #92661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92661 2019-01-04T09:38:04 Z Kastanda Cipele (COCI18_cipele) C++11
90 / 90
52 ms 3060 KB
#include<bits/stdc++.h>
using namespace std;
int n, m;
vector < int > A, B;
bool Solve(int md)
{
    int r = 0;
    for (int i = 0; i < A.size(); i++)
    {
        if (r >= B.size())
            return false;
        while (r < B.size() && B[r] <= A[i] && A[i] - B[r] > md)
            r ++;
        if (r >= B.size() || abs(A[i] - B[r]) > md)
            return false;
        r ++;
    }
    return true;
}
int main()
{
    scanf("%d%d", &n, &m);
    A.resize(n); B.resize(m);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    for (int i = 0; i < m; i++)
        scanf("%d", &B[i]);
    if (n > m) A.swap(B);
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int le = -1, ri = 1e9, md;
    while (ri - le > 1)
    {
        md = (le + ri) >> 1;
        if (Solve(md))
            ri = md;
        else
            le = md;
    }
    return !printf("%d", ri);
}

Compilation message

cipele.cpp: In function 'bool Solve(int)':
cipele.cpp:8:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < A.size(); i++)
                     ~~^~~~~~~~~~
cipele.cpp:10:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (r >= B.size())
             ~~^~~~~~~~~~~
cipele.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (r < B.size() && B[r] <= A[i] && A[i] - B[r] > md)
                ~~^~~~~~~~~~
cipele.cpp:14:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (r >= B.size() || abs(A[i] - B[r]) > md)
             ~~^~~~~~~~~~~
cipele.cpp: In function 'int main()':
cipele.cpp:22: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:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
cipele.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &B[i]);
         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 2652 KB Output is correct
2 Correct 52 ms 3060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 2936 KB Output is correct
2 Correct 52 ms 2980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 2488 KB Output is correct
2 Correct 31 ms 1784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 2680 KB Output is correct
2 Correct 31 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 2428 KB Output is correct
2 Correct 45 ms 2680 KB Output is correct