Submission #361256

# Submission time Handle Problem Language Result Execution time Memory
361256 2021-01-29T00:49:35 Z daringtrifles Cipele (COCI18_cipele) C++17
90 / 90
55 ms 3820 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define FOR(i, a, b) for (signed ll i = (signed ll)(a); i < (signed ll)(b); i++)
#define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--)
#define vll vector<ll>
#define sll set<ll>
#define ld long double
#define inf 10000000005
#define mll multiset<ll>
#define vpll vector<pll>
#define nn << "\n"
#define ss << " "
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18
ll l, r;
const ll mxn=1e5+5;
vll le(mxn), ri(mxn);
bool check(ll n)
{
    if (l > r)
    {
        swap(l, r);
        swap(le, ri);
    }
    ll j=0;
    for (auto i:le){
        while (abs(i-ri[j])>n&&j<r){
            j++;
        }
        //if(n==10000000005) cout<<ri[j] ss;
        if(j==r) return 0;
        j++;
    }
    return 1;
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> l >> r;
    le.resize(l);
    ri.resize(r);
    FOR(i, 0, l)
    {
        cin>>le[i];
    }
    FOR(i, 0, r)
    {
        cin>>ri[i];
    }
    sort(le.begin(),le.end());
    sort(ri.begin(),ri.end());
    ll l=-1, r=inf;
 
    while (check(r)){
        ll mid=l+(r-l)/2;
        //cout<<mid <<endl;
        if (check(mid)){
            r=mid-1;
            //if (r==0) cout<<"yes";
        }
        else{
            l=mid+1;
        }
    }
    cout<<r+1;
}
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2796 KB Output is correct
2 Correct 47 ms 3692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 2732 KB Output is correct
2 Correct 47 ms 3820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1900 KB Output is correct
2 Correct 4 ms 2028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1900 KB Output is correct
2 Correct 4 ms 2028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1900 KB Output is correct
2 Correct 4 ms 2028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1900 KB Output is correct
2 Correct 4 ms 2028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1900 KB Output is correct
2 Correct 4 ms 2028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 2668 KB Output is correct
2 Correct 30 ms 2924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 2668 KB Output is correct
2 Correct 27 ms 3112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2668 KB Output is correct
2 Correct 41 ms 3436 KB Output is correct