Submission #197860

# Submission time Handle Problem Language Result Execution time Memory
197860 2020-01-23T17:51:16 Z Osama_Alkhodairy Cipele (COCI18_cipele) C++17
0 / 90
1000 ms 7416 KB
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, m;
vector <int> a, b;

bool check(int x){
    set <int> s(b.begin(), b.end());
    for(auto &i : a){
        auto it = s.lower_bound(i - x);
        if(it == s.end()) return 0;
        if(*it - i > x) return 0;
        s.erase(it);
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    a.resize(n);
    for(auto &i : a) cin >> i;
    b.resize(m);
    for(auto &i : b) cin >> i;
    if(b.size() < a.size()) swap(a, b);
    sort(a.begin(), a.end());
    int l = 0, r = 1e9;
    while(l <= r){
        int mid = (l + r) / 2;
        if(check(mid)) r = mid - 1;
        else l = mid + 1;
    }
    cout << l << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 389 ms 7416 KB Output is correct
2 Execution timed out 1069 ms 7416 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 7288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 504 KB Output is correct
2 Incorrect 37 ms 752 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 764 KB Output is correct
2 Incorrect 37 ms 632 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 632 KB Output is correct
2 Incorrect 36 ms 804 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1010 ms 6872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 6956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 6660 KB Time limit exceeded
2 Halted 0 ms 0 KB -