Submission #82280

# Submission time Handle Problem Language Result Execution time Memory
82280 2018-10-29T17:38:27 Z Milki Cipele (COCI18_cipele) C++14
90 / 90
52 ms 1404 KB
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)

typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 1e5 + 5;

int n, m;
int a[MAXN], b[MAXN];

bool check(int x){
    int curr = 0;
    REP(i, m){
        if(curr >= n) return false;
        while(abs(a[curr] - b[i]) > x && curr < n)
            curr ++;
        if(curr == n)
            return false;
        curr ++;
    }
    return true;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);

    cin >> n >> m;
    REP(i, n)
        cin >> a[i];
    REP(i, m)
        cin >> b[i];
    sort(a, a + n);
    sort(b, b + m);
    if(n < m){
        swap(a, b);
        swap(n, m);
    }

    int lo = 0, hi = 1e9;
    while(lo < hi){
        int mid = (lo + hi) >> 1;
        if(check(mid))
            hi = mid;
        else
            lo = mid + 1;
    }
    cout << lo;
}
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1144 KB Output is correct
2 Correct 49 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 1216 KB Output is correct
2 Correct 49 ms 1316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1368 KB Output is correct
2 Correct 5 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Correct 5 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1384 KB Output is correct
2 Correct 5 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1388 KB Output is correct
2 Correct 5 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1388 KB Output is correct
2 Correct 6 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 1388 KB Output is correct
2 Correct 30 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1388 KB Output is correct
2 Correct 24 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1404 KB Output is correct
2 Correct 45 ms 1404 KB Output is correct