Submission #745649

#TimeUsernameProblemLanguageResultExecution timeMemory
745649MilosMilutinovicCipele (COCI18_cipele)C++14
90 / 90
42 ms2876 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, m, a[N], b[N]; bool check(int x) { int ptr = 1; for (int i = 1; i <= n; i++) { while (ptr <= m && a[i] - x > b[ptr]) ptr++; if (ptr == m + 1 || a[i] + x < b[ptr]) return false; ptr++; } return true; } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= m; i++) scanf("%d", &b[i]); sort(a + 1, a + n + 1); sort(b + 1, b + m + 1); if (n > m) { swap(n, m); for (int i = 1; i < N; i++) swap(a[i], b[i]); } int low = 0, high = 1e9, ans = 0; while (low <= high) { int mid = low + high >> 1; if (check(mid)) ans = mid, high = mid - 1; else low = mid + 1; } printf("%d", ans); return 0; }

Compilation message (stderr)

cipele.cpp: In function 'int main()':
cipele.cpp:26:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |         int mid = low + high >> 1;
      |                   ~~~~^~~~~~
cipele.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:16:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
      |                                  ~~~~~^~~~~~~~~~~~~
cipele.cpp:17:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
      |                                  ~~~~~^~~~~~~~~~~~~
#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...