# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146395 | 2019-08-23T18:24:53 Z | badrovinho | Cipele (COCI18_cipele) | C++14 | 166 ms | 2952 KB |
#include <iostream> #include <bits/stdc++.h> #include <algorithm> #include <vector> #include <string> #include <cstring> using namespace std; int l[100005]; int r[100005]; int main (){ int n,m; cin >> n >> m; for (int i = 0; i < n; i++){ cin >> l[i]; } for (int i = 0; i < m; i++){ cin >> r[i]; } sort(l, l + n); sort(r, r + m); int lo = 0; int hi = 1000000000; int mid = hi / 2; while (lo != hi){ if (n > m){ int raz = n - m; int ptl = 0; int ptr = 0; int sol = true; for (int i = 0; i < m; i++){ while (raz && abs(l[ptl] - r[i]) > mid) { raz--; ptl++; } if (abs(l[ptl] - r[i]) > mid) { sol = false; break; } ptl++; } if (!sol){ lo = mid+1; mid = (hi+lo)/2; }else { hi = mid; mid = (hi+lo)/2; } } else { int raz = m - n; int ptl = 0; int ptr = 0; int sol = true; for (int i = 0; i < n; i++){ while (raz && abs(l[i] - r[ptr]) > mid) { raz--; ptr++; } if (abs(l[i] - r[ptr]) > mid) { sol = false; break; } ptr++; } if (!sol){ lo = mid+1; mid = (hi+lo)/2; }else { hi = mid; mid = (hi+lo)/2; } } // cout << "srednji mid je --> " << mid << endl; } cout << mid; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 131 ms | 2692 KB | Output is correct |
2 | Correct | 160 ms | 2952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 160 ms | 2936 KB | Output is correct |
2 | Correct | 166 ms | 2936 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 10 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 10 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 408 KB | Output is correct |
2 | Correct | 10 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 460 KB | Output is correct |
2 | Correct | 10 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 376 KB | Output is correct |
2 | Correct | 10 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 139 ms | 2500 KB | Output is correct |
2 | Correct | 93 ms | 1988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 145 ms | 2620 KB | Output is correct |
2 | Correct | 99 ms | 2072 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 136 ms | 2512 KB | Output is correct |
2 | Correct | 139 ms | 2552 KB | Output is correct |