Submission #916560

# Submission time Handle Problem Language Result Execution time Memory
916560 2024-01-26T06:03:08 Z 406 Cipele (COCI18_cipele) C++17
90 / 90
42 ms 3796 KB
#include <bits/stdc++.h>
#define int int64_t
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ar = array<int, 2>;

const int64_t INF = 1ll << 60;
const int N = 1e5 + 5;
vector<int> L, R;
int n, m;

bool check(int x) {
       int p = 0;
       FOR(i, 0, n) {
                while (p < m && abs(R[p] - L[i]) > x) ++p;
                if (p == m) return false;
                ++p;
       }
       return true;
}

signed main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr); 
        cin >> n >> m;
        L.resize(n); R.resize(m);
        for (auto &i: L) cin >> i;
        for (auto &i: R) cin >> i;
        if (n > m) {
                swap(n, m);
                swap(L, R);
        }
        sort(L.begin(), L.end());
        sort(R.begin(), R.end());

        int l = -1, r = INF;
        while (l + 1 < r) {
                int m = l + r >> 1;
                if (check(m)) r = m;
                else l = m;
        }
        cout << r << '\n';
        return 0;
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:39:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   39 |                 int m = l + r >> 1;
      |                         ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3420 KB Output is correct
2 Correct 34 ms 3796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 3692 KB Output is correct
2 Correct 42 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 3164 KB Output is correct
2 Correct 21 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3416 KB Output is correct
2 Correct 19 ms 2512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3284 KB Output is correct
2 Correct 33 ms 3164 KB Output is correct