Submission #757278

#TimeUsernameProblemLanguageResultExecution timeMemory
757278racsosabeCipele (COCI18_cipele)C++14
90 / 90
52 ms2856 KiB
#include<bits/stdc++.h> using namespace::std; const int N = 100000 + 5; int n; int m; int a[N]; int b[N]; bool can(int L) { int at = 1; for(int i = 1; i <= n; i++) { while(at <= m and b[at] < a[i] - L) at += 1; if(at <= m and b[at] <= a[i] + L) { at += 1; continue; } return false; } return true; } void swap() { for(int i = 1; i <= max(n, m); i++) swap(a[i], b[i]); swap(n, m); } 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); if(n > m) swap(); sort(a + 1, a + n + 1); sort(b + 1, b + m + 1); int lo = 0, hi = 1000000000; while(lo < hi) { int mi = lo + (hi - lo) / 2; if(not can(mi)) lo = mi + 1; else hi = mi; } printf("%d\n", lo); return 0; }

Compilation message (stderr)

cipele.cpp: In function 'int main()':
cipele.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
cipele.cpp:31:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     for(int i = 1; i <= n; i++) scanf("%d", a + i);
      |                                 ~~~~~^~~~~~~~~~~~~
cipele.cpp:32:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     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...