Submission #672851

#TimeUsernameProblemLanguageResultExecution timeMemory
672851tvladm2009Cipele (COCI18_cipele)C++14
90 / 90
55 ms3168 KiB
#include <bits/stdc++.h> using ll = long long; bool check(int x, std::vector<int> left, std::vector<int> right) { int ptr1 = 0, ptr2 = 0; int cnt = 0; while(ptr1 < left.size() && ptr2 < right.size()) { if(abs(left[ptr1] - right[ptr2]) <= x) { cnt++; ptr1++; ptr2++; } else ptr2++; } return (cnt == left.size()); } int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n, m; std::cin >> n >> m; std::vector<int> x(n), y(m); for(int i = 0;i < n; i++) std::cin >> x[i]; for(int i = 0;i < m; i++) std::cin >> y[i]; std::sort(x.begin(), x.end()); std::sort(y.begin(), y.end()); if(n > m) { std::swap(n, m); std::swap(x, y); } int from = 0, to = 1e9, result = 0; while(from <= to) { int mid = (from + to) / 2; if(check(mid, x, y)) { result = mid; to = mid - 1; } else from = mid + 1; } std::cout << result; return 0; }

Compilation message (stderr)

cipele.cpp: In function 'bool check(int, std::vector<int>, std::vector<int>)':
cipele.cpp:8:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |   while(ptr1 < left.size() && ptr2 < right.size()) {
      |         ~~~~~^~~~~~~~~~~~~
cipele.cpp:8:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |   while(ptr1 < left.size() && ptr2 < right.size()) {
      |                               ~~~~~^~~~~~~~~~~~~~
cipele.cpp:16:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   return (cnt == left.size());
      |           ~~~~^~~~~~~~~~~~~~
#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...