Submission #1096079

#TimeUsernameProblemLanguageResultExecution timeMemory
1096079thangdz2k7Cipele (COCI18_cipele)C++17
90 / 90
30 ms2904 KiB
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int MaxN = 2e5; const int mod = 1e9 + 7; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} void solve(){ int n, m; cin >> n >> m; vi a(n), b(m); for (auto &p : a) cin >> p; for (auto &p : b) cin >> p; sort(a.begin(), a.end()); sort(b.begin(), b.end()); if (n > m){ swap(n, m); swap(a, b); } int lo = 0, hi = 1e9, ans = hi; while (lo <= hi){ int mid = lo + hi >> 1; int l = 0; bool ck = true; for (int p : a){ while (l < m && p - b[l] > mid) ++ l; if (l == m || b[l] - p > mid) { ck = false; break; } ++ l; } if (ck) ans = mid, hi = mid - 1; else lo = mid + 1; } cout << ans; } int main(){ if (fopen("pqh.inp", "r")){ freopen("pqh.inp", "r", stdin); freopen("pqh.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t --) solve(); return 0; }

Compilation message (stderr)

cipele.cpp:18:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
cipele.cpp:18:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
cipele.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
cipele.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
cipele.cpp: In function 'void solve()':
cipele.cpp:34:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |         int mid = lo + hi >> 1;
      |                   ~~~^~~~
cipele.cpp: In function 'int main()':
cipele.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
cipele.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...