Submission #146179

#TimeUsernameProblemLanguageResultExecution timeMemory
146179fabjanmCipele (COCI18_cipele)C++98
90 / 90
179 ms3240 KiB
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<cmath> using namespace std; int n,m; vector<int>lef; vector<int>righ; void input(){ cin>>n>>m; int br; for(int i=0;i<n;i++){ cin>>br; lef.push_back(br); } for(int i=0;i<m;i++){ cin>>br; righ.push_back(br); } //cout<<lef.size()<<" "<<righ.size()<<endl; } bool prov(int ruz){ if(lef.size()<=righ.size()){ int pos=0; for(int i=0;i<righ.size();i++){ //cout<<pos<<" -----> "<<lef[pos]<<" "<<righ[i]<<endl; if(pos==lef.size())return true; if(abs(lef[pos]-righ[i])<=ruz)pos++; } if(pos!=lef.size())return false; else return true; } else{ int pos=0; for(int i=0;i<lef.size();i++){ if(pos==righ.size())return true; if(abs(righ[pos]-lef[i])<=ruz)pos++; } if(pos!=righ.size())return false; else return true; } } void solve(){ sort(lef.begin(),lef.end()); sort(righ.begin(),righ.end()); int lo=0,hi=1000000000; while(lo<hi){ int mid=(lo+hi)/2; ///cout<<mid<<"->>>>>>>>"<<endl; if(prov(mid)){ hi=mid; } else{ lo=mid+1; } //cout<<lo<<" --> "<<hi<<endl<<endl; } cout<<lo; } int main(){ input(); solve(); return 0; }

Compilation message (stderr)

cipele.cpp: In function 'bool prov(int)':
cipele.cpp:32:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<righ.size();i++){
               ~^~~~~~~~~~~~
cipele.cpp:34:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(pos==lef.size())return true;
       ~~~^~~~~~~~~~~~
cipele.cpp:38:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(pos!=lef.size())return false;
      ~~~^~~~~~~~~~~~
cipele.cpp:43:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<lef.size();i++){
               ~^~~~~~~~~~~
cipele.cpp:44:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(pos==righ.size())return true;
       ~~~^~~~~~~~~~~~~
cipele.cpp:47:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(pos!=righ.size())return false;
      ~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...