Submission #166424

#TimeUsernameProblemLanguageResultExecution timeMemory
166424tincamateiCipele (COCI18_cipele)C++14
90 / 90
98 ms3156 KiB
#include <bits/stdc++.h> using namespace std; vector<int> v1, v2; bool check(int T) { int j = 0; for(int i = 0; i < v1.size(); ++i) { while(j < v2.size() && abs(v2[j] - v1[i]) > T) ++j; if(j == v2.size()) return false; ++j; } return true; } int main() { int n, m, x; scanf("%d%d", &n, &m); for(int i = 0; i < n; ++i) { scanf("%d", &x); v1.push_back(x); } for(int i = 0; i < m; ++i) { scanf("%d", &x); v2.push_back(x); } if(v1.size() > v2.size()) v1.swap(v2); sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); int st = -1, dr = 1000000001; while(dr - st > 1) { int mid = (st + dr) / 2; if(check(mid)) dr = mid; else st = mid; } printf("%d", dr); return 0; }

Compilation message (stderr)

cipele.cpp: In function 'bool check(int)':
cipele.cpp:9:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < v1.size(); ++i) {
                  ~~^~~~~~~~~~~
cipele.cpp:10:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(j < v2.size() && abs(v2[j] - v1[i]) > T)
           ~~^~~~~~~~~~~
cipele.cpp:12:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(j == v2.size())
        ~~^~~~~~~~~~~~
cipele.cpp: In function 'int main()':
cipele.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &x);
     ~~~~~^~~~~~~~~~
cipele.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     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...