Submission #646123

#TimeUsernameProblemLanguageResultExecution timeMemory
646123Hacv16Cipele (COCI18_cipele)C++17
81 / 90
46 ms4912 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define sc second #define fr first #define all(x) x.begin(), x.end() #define sz(x) (ll) x.size() #define dbg(x) cerr << #x << ": [ " << x << " ]\n" typedef long long ll; typedef pair<int, int> pii; const int MAX = 2e6 + 15; const int INF = 0x3f3f3f3f; ll n, m; vector<ll> l, r; bool f(ll x){ ll shoes = 0; for(int i = 0, j = 0; i < n, j < m; i++, j++){ while(j < m && abs(r[j] - l[i]) > x) j++; if(j != m) shoes++; } return shoes >= n; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for(int i = 0; i < n; i++){ ll x; cin >> x; l.pb(x); } for(int i = 0; i < m; i++){ ll x; cin >> x; r.pb(x); } if(n > m) swap(l, r), swap(n, m); //always make l the smaller one sort(all(l)); sort(all(r)); ll l = 0, r = INF, ans = INF; while(l <= r){ ll mid = (l + r) >> 1; if(f(mid)) ans = mid, r = mid - 1; else l = mid + 1; } cout << ans << '\n'; return 0; }

Compilation message (stderr)

cipele.cpp: In function 'bool f(ll)':
cipele.cpp:23:29: warning: left operand of comma operator has no effect [-Wunused-value]
   23 |     for(int i = 0, j = 0; i < n, j < m; i++, j++){
      |                           ~~^~~
#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...