# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
646125 | 2022-09-28T18:12:44 Z | Hacv16 | Cipele (COCI18_cipele) | C++17 | 39 ms | 2660 KB |
#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(ll 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 2640 KB | Output is correct |
2 | Correct | 38 ms | 2660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 2632 KB | Output is correct |
2 | Correct | 39 ms | 2656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 352 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 31 ms | 2400 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 35 ms | 2512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 31 ms | 2288 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |