Submission #146200

# Submission time Handle Problem Language Result Execution time Memory
146200 2019-08-22T19:44:19 Z miljenko_jabucica Cipele (COCI18_cipele) C++11
90 / 90
164 ms 3216 KB
#include<bits/stdc++.h>

using namespace std;
int n, m;
vector<int> desne;
vector<int> lijeve;
int low;
int hig;
bool prov(int ruznoca){
    int ind = 0;
    int sparene = 0;
    if (lijeve.size() > desne.size()){
        for (int i = 0; i < lijeve.size(); ++i){
            if (abs(lijeve[i]-desne[ind]) <= ruznoca)++ind;
            if (ind == desne.size()){
                sparene = 1;
                break;
            }
        }
    }else{
        for (int i = 0; i < desne.size(); ++i){
            if (abs(desne[i]-lijeve[ind]) <= ruznoca)++ind;
            if (ind == lijeve.size()){
                sparene = 1;
                break;
            }
        }
    }
    if (sparene == 0)return 0;
    else return 1;
}
int binarisrtj(){
    low = 0;
    hig = 1000000000;
    while (hig-low>0){
        int mid = (hig + low)/2;
        ///cout <<low <<" " <<mid <<" " <<hig <<endl;
        if (prov(mid))hig=mid;
        else low = mid+1;
        ///cout <<low <<" " <<mid <<" " <<hig <<" " <<prov(mid) <<endl;
    }
    return low;
}
int main(){
    cin >>n >>m;
    for (int i = 0; i < n; ++i){
        int x;
        cin >>x;
        desne.push_back(x);
    }
    for (int i = 0; i < m; ++i){
        int x;
        cin >>x;
        lijeve.push_back(x);
    }
    sort(desne.begin(), desne.end());
    sort(lijeve.begin(), lijeve.end());
    cout <<binarisrtj();
    //cout <<prov(3);
return 0;
}

Compilation message

cipele.cpp: In function 'bool prov(int)':
cipele.cpp:13:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < lijeve.size(); ++i){
                         ~~^~~~~~~~~~~~~~~
cipele.cpp:15:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (ind == desne.size()){
                 ~~~~^~~~~~~~~~~~~~~
cipele.cpp:21:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < desne.size(); ++i){
                         ~~^~~~~~~~~~~~~~
cipele.cpp:23:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (ind == lijeve.size()){
                 ~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 133 ms 1520 KB Output is correct
2 Correct 162 ms 3216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 161 ms 1520 KB Output is correct
2 Correct 164 ms 3108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 10 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 10 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 10 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 10 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 11 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 140 ms 1352 KB Output is correct
2 Correct 94 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 1364 KB Output is correct
2 Correct 98 ms 2328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 134 ms 1364 KB Output is correct
2 Correct 138 ms 3032 KB Output is correct