Submission #651701

# Submission time Handle Problem Language Result Execution time Memory
651701 2022-10-19T20:40:29 Z ktkerem Cipele (COCI18_cipele) C++17
90 / 90
53 ms 3788 KB
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll , ll> llll;
typedef std::string str;
#define all(a) a.begin() , a.end()
std::vector<ll> ar , br;
ll n , m;
void solve(){
    std::cin >> n >> m;
    ar.resize(n);
    br.resize(m);
    for(ll i = 0;n>i;i++){
        std::cin >> ar[i];
    }
    for(ll i = 0;m>i;i++){
        std::cin >> br[i];   
    }
    if(n > m){
        std::swap(n , m);
        std::swap(ar , br);
    }
    std::sort(all(ar));
    std::sort(all(br));
    ll l = 0 , r = 1e9;
    while(r > l){
        ll md = (l + r)/2;
        ll i = n - 1, j = m - 1;
        while(i >= 0 && j >= 0){
            if(llabs(ar[i] - br[j]) > md){
                j--;
            }
            else{
                i--;j--;
            }
        }
        //std::cout << l << " " << r << " " << md << std::endl;
        if(i != -1){
            l = md + 1;
        }
        else{
            r = md;
        }
    }
    std::cout << l << "\n";
}

int main(){
    std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
    ll t = 1;
    //std::cin >> t;
    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3404 KB Output is correct
2 Correct 48 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 3788 KB Output is correct
2 Correct 48 ms 3660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 440 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 3020 KB Output is correct
2 Correct 29 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 3236 KB Output is correct
2 Correct 30 ms 2496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2980 KB Output is correct
2 Correct 43 ms 3140 KB Output is correct