Submission #892339

#TimeUsernameProblemLanguageResultExecution timeMemory
892339LittleFlowers__Cipele (COCI18_cipele)C++17
90 / 90
32 ms2908 KiB
#include <bits/stdc++.h> using namespace std; int32_t main() { if (fopen("input.txt", "r")) { freopen("input.txt", "r", stdin); } cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; vector<int> a(n), b(m); for (int &i : a) cin >> i; for (int &i : b) cin >> i; if (n > m) swap(n, m), swap(a, b); sort(a.begin(), a.end()); sort(b.begin(), b.end()); int le = 0, mi, ri = 1e9, answer; while (le <= ri) { mi = (le + ri) / 2; bool okay = true; int j = 0; for (int i = 0; i < a.size(); ++i) { while (j < b.size() && abs(a[i] - b[j]) > mi) j += 1; if (j == b.size()) { okay = false; break; } j += 1; } if (okay) answer = mi, ri = mi - 1; else le = mi + 1; } cout << answer << '\n'; }

Compilation message (stderr)

cipele.cpp: In function 'int32_t main()':
cipele.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < a.size(); ++i) {
      |                     ~~^~~~~~~~~~
cipele.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |       while (j < b.size() && abs(a[i] - b[j]) > mi) j += 1;
      |              ~~^~~~~~~~~~
cipele.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |       if (j == b.size()) { okay = false; break; }
      |           ~~^~~~~~~~~~~
cipele.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cipele.cpp:41:21: warning: 'answer' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |   cout << answer << '\n';
      |                     ^~~~
#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...