Submission #560210

# Submission time Handle Problem Language Result Execution time Memory
560210 2022-05-11T07:13:19 Z AGE Cipele (COCI18_cipele) C++14
0 / 90
859 ms 8320 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define int long long
using namespace std;
const int N=1e5+5,M=2e3+10,mod=100000000000031;
vector<int>v;

long long  summ(long long  x,long long  y){
    return ((x%mod)+(y%mod))%mod;
}

long long  mult(long long  x,long long  y){
    return ((x%mod)*(y%mod))%mod;
}

int n,m,a[N],b[N];
bool ok(int mid){

    set<int>st;

    for(int i=0;i<n;i++)
        st.insert(-a[i]);

    int i=0,okk=0;

    while(i<m){

        while(st.size()!=0&&abs(b[i]-abs(*st.begin()))>mid)
            st.erase(st.begin());

        if(st.size()==0){
            okk=1;
            break;
        }

        i++;
        st.erase(st.begin());

    }

    return !okk;
}
main()
{
    cin>>n>>m;

    for(int i=0;i<n;i++)
        cin>>a[i];

    for(int i=0;i<m;i++)
        cin>>b[i];

    sort(b,b+m);
    reverse(b,b+m);

    int l=0,r=1e9;

    while(l<r){

        int mid=(l+r)/2;

        if(ok(mid))
            r=mid;

        else l=mid+1;

    }

    cout<<r<<endl;


    return 0;
}

Compilation message

cipele.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 617 ms 7480 KB Output is correct
2 Incorrect 859 ms 8320 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 859 ms 7560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 499 ms 5412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 757 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 538 ms 5328 KB Output isn't correct
2 Halted 0 ms 0 KB -