Submission #165476

#TimeUsernameProblemLanguageResultExecution timeMemory
165476SenseiCipele (COCI18_cipele)C++17
90 / 90
109 ms4056 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5; bool check (deque<int> a, deque<int> b, int val) { if (a.size() > b.size()) { swap(a, b); } for (int i = 0; i < a.size(); i++) { while (b.size() > 0 && abs(b[0] - a[i]) > val) { b.pop_front(); } if (b.size() == 0) { return false; } else { b.pop_front(); } } return true; } int main () { int N, M; cin >> N >> M; deque<int> a(N); deque<int> b(M); for (int i = 0; i < N; i++) { scanf("%d", &a[i]); } sort(a.begin(), a.end()); for (int i = 0; i < M; i++) { scanf("%d", &b[i]); } sort(b.begin(), b.end()); int ss = 0, se = 1e9; int jump = 1; while (ss + jump * 2 <= se) { jump *= 2; } for (; jump > 0; jump /= 2) { int mid = se - jump; if (mid < ss) { continue; } if (check(a, b, mid)) { se = mid; } else { ss = mid + 1; } } cout << se << "\n"; return 0; }

Compilation message (stderr)

cipele.cpp: In function 'bool check(std::deque<int>, std::deque<int>, int)':
cipele.cpp:12:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.size(); i++) {
                  ~~^~~~~~~~~~
cipele.cpp: In function 'int main()':
cipele.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
cipele.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   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...