Submission #82278

# Submission time Handle Problem Language Result Execution time Memory
82278 2018-10-29T17:36:16 Z Milki Cipele (COCI18_cipele) C++14
72 / 90
60 ms 1548 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 && abs(a[curr] - b[i]) > x)
            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 35 ms 1144 KB Output is correct
2 Correct 60 ms 1216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 1232 KB Output is correct
2 Correct 53 ms 1232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1232 KB Output is correct
2 Correct 5 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1308 KB Output is correct
2 Incorrect 5 ms 1308 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1308 KB Output is correct
2 Correct 6 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1384 KB Output is correct
2 Incorrect 5 ms 1384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1388 KB Output is correct
2 Correct 5 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 1548 KB Output is correct
2 Correct 33 ms 1548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1548 KB Output is correct
2 Correct 25 ms 1548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1548 KB Output is correct
2 Correct 46 ms 1548 KB Output is correct