Submission #82054

# Submission time Handle Problem Language Result Execution time Memory
82054 2018-10-28T20:40:37 Z josiftepe Cipele (COCI18_cipele) C++14
90 / 90
75 ms 2888 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 1e5 + 10;
int n, m;
vector<ll> L, R;
bool check(ll x){
    int cnt = 0;
    for(int i = 0; i < m; i ++){
        if(cnt >= n){
            return true;
        }
        if(llabs(R[i] - L[cnt]) > x){
            continue;
        }
        cnt ++;
    }
    return (cnt >= n);
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
//    ifstream cin("in.txt");
    cin >> n >> m;
    ll num;
    for(int i = 0; i < n; i ++){
        cin >> num;
        L.push_back(num);
    }
    for(int i = 0; i < m; i ++){
        cin >> num;
        R.push_back(num);
    }
    if(n > m){
        swap(L, R);
    }
    n = (int)L.size();
    m = (int)R.size();
    sort(L.begin(), L.end());
    sort(R.begin(), R.end());
    ll levo = 0, desno = (1LL << 40LL);
//    for(int i = 0; i < n; i ++){
//        cout << L[i] << " ";
//    }
//    cout << endl;
//    for(int i =0 ; i < m; i++){
//        cout << R[i] << " ";
//    }
//    cout<<endl;
//    cout << check(4) << endl;
    ll ret = -1;
    while(levo <= desno){
        ll mid = levo + ((desno - levo) / 2LL);
        if(check(mid)){
            desno = mid  -1;
            ret = mid;
        }
        else{
            levo = mid +1;
        }
    }
    cout << ret << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 61 ms 2772 KB Output is correct
2 Correct 75 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 2772 KB Output is correct
2 Correct 75 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 5 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 5 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2852 KB Output is correct
2 Correct 5 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2852 KB Output is correct
2 Correct 5 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2852 KB Output is correct
2 Correct 6 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 2852 KB Output is correct
2 Correct 43 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 2852 KB Output is correct
2 Correct 40 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 2852 KB Output is correct
2 Correct 63 ms 2888 KB Output is correct