Submission #472389

# Submission time Handle Problem Language Result Execution time Memory
472389 2021-09-13T12:50:46 Z BidoTeima Cipele (COCI18_cipele) C++17
0 / 90
174 ms 18068 KB
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS(){
#ifndef ONLINE_JUDGE
    freopen("output.txt","w",stdout);
    freopen("input.txt","r",stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define tc int tttttt;cin>>tttttt;while(tttttt--)
#define sumrange(l,r,arr) (l==0?arr[r]:arr[r]-arr[l-1])
bool isint(const string& s){
    bool ok=1;
    for(char i:s)
        ok&=isdigit(i);
    return ok;
}
bool isseq(const string& s){
    return !isint(s);
}
int main(){
    ACPLS();
    int n,m;
    cin>>n>>m;
    int a[n];
    for(auto&i:a)cin>>i;
    multiset<int>b;
    for(int i = 0; i < m; i++){
        ll x;
        cin>>x;
        b.insert(x);
    }
    int lo=0,hi=1e9,ans=hi;
    sort(a,a+n);
    while(lo<=hi){
        ll mid=(lo+hi)/2;
        multiset<int>ms=b;
        bool ok = 1;
        for(int i = 0; i < n; i++){
            if(ms.empty())break;
            auto it = ms.lower_bound(a[i]-mid);
            if(it==ms.end()||abs((*it)-a[i])>mid){
                ok=0;
                break;
            }
            ms.erase(it);
        }
        if(ok){
            ans=mid;
            hi=mid-1;
        }else lo=mid+1;
    }
    cout<<ans;
}

Compilation message

cipele.cpp: In function 'void ACPLS()':
cipele.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cipele.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 17996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 18048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 143 ms 17996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 17968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 18060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 18060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 173 ms 18060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 17992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 17996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 18068 KB Output isn't correct
2 Halted 0 ms 0 KB -