Submission #888832

# Submission time Handle Problem Language Result Execution time Memory
888832 2023-12-18T08:25:54 Z dimashhh Cipele (COCI18_cipele) C++17
90 / 90
34 ms 4484 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 1, MOD = 1e9 + 9;
typedef long long ll;

int n,m,a[N],b[N];
bool f(int mid){
    int it = 1;
    for(int i = 1;i <= n;i++){
        while(it <= m && abs(b[it] - a[i]) > mid)
            it++;
        if(it > m) return false;
        it++;
    }
    return 1;
}
void test(){
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    for(int i = 1;i <= m;i++){
        cin >> b[i];
    }
    if(n > m){
        for(int i = 1;i <= n;i++){
            swap(a[i],b[i]);
        }
        swap(n,m);
    }
    sort(a + 1,a + n + 1);
    sort(b + 1,b + m + 1);
    ll l = -1,r = 2e9;
    while(r - l > 1){
        ll mid = (l + r) >> 1;
        if(f(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;//cin >> T;
    while (T--) test();
}
# Verdict Execution time Memory Grader output
1 Correct 21 ms 4168 KB Output is correct
2 Correct 31 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 4484 KB Output is correct
2 Correct 31 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 3 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 4036 KB Output is correct
2 Correct 19 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 4188 KB Output is correct
2 Correct 18 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3932 KB Output is correct
2 Correct 28 ms 4188 KB Output is correct