Submission #146199

# Submission time Handle Problem Language Result Execution time Memory
146199 2019-08-22T19:42:31 Z miljenko_jabucica Cipele (COCI18_cipele) C++14
0 / 90
165 ms 3100 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 Incorrect 136 ms 2928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 165 ms 3100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 155 ms 2788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 153 ms 2992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 147 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -