Submission #699722

#TimeUsernameProblemLanguageResultExecution timeMemory
699722inwbearCipele (COCI18_cipele)C++14
90 / 90
49 ms3068 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back int n,m,x,ans,st,ed,md; vector<int>l,r; bool chk(int k){ int cur=0,co=0; for(int i=0;i<l.size();i++){ while(abs(l[i]-r[cur])>k){ cur++; if(cur>=r.size())break; } if(cur>=r.size())break; co++; cur++; if(cur>=r.size())break; } if(co==l.size())return true; else return false; } int main(){ scanf("%d %d",&n,&m); for(int i=0;i<n;i++){ scanf("%d",&x); l.pb(x); } for(int i=0;i<m;i++){ scanf("%d",&x); r.pb(x); } sort(l.begin(),l.end()); sort(r.begin(),r.end()); if(m<n)swap(n,m),swap(l,r); ans=INT_MAX,st=0,ed=(int)1e9; while(st<=ed){ md=(st+ed)/2; if(chk(md)){ ans=min(ans,md); ed=md-1; } else{ st=md+1; } } printf("%d",ans); }

Compilation message (stderr)

cipele.cpp: In function 'bool chk(int)':
cipele.cpp:8:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |   for(int i=0;i<l.size();i++){
      |               ~^~~~~~~~~
cipele.cpp:11:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |       if(cur>=r.size())break;
      |          ~~~^~~~~~~~~~
cipele.cpp:13:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     if(cur>=r.size())break;
      |        ~~~^~~~~~~~~~
cipele.cpp:16:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     if(cur>=r.size())break;
      |        ~~~^~~~~~~~~~
cipele.cpp:18:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if(co==l.size())return true;
      |      ~~^~~~~~~~~~
cipele.cpp: In function 'int main()':
cipele.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%d %d",&n,&m);
      |   ~~~~~^~~~~~~~~~~~~~~
cipele.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d",&x);
      |     ~~~~~^~~~~~~~~
cipele.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d",&x);
      |     ~~~~~^~~~~~~~~
#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...