# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
197035 | 2020-01-18T08:17:40 Z | quocnguyen1012 | Cipele (COCI18_cipele) | C++14 | 57 ms | 3164 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; vector<int> a, b; int N, M; bool check(int val) { int j = M - 1; for (int i = N - 1; i >= 0; --i){ while (j >= 0 && abs(a[i] - b[j]) > val) --j; if(j < 0){ return false; } --j; } return true; } signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("A.INP", "r")){ freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); } cin >> N >> M; a.resize(N); b.resize(M); for (auto & x : a) cin >> x; for (auto & x : b) cin >> x; sort(a.begin(), a.end()); sort(b.begin(), b.end()); if (N > M){ swap(a, b); swap(N, M); } int l = 0, r = 1e9, mid; while (l <= r){ mid = (l + r) / 2; if (!check(mid)) l = mid + 1; else r = mid - 1; } cout << l; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 2680 KB | Output is correct |
2 | Correct | 57 ms | 3164 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 3064 KB | Output is correct |
2 | Correct | 45 ms | 2952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 4 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 4 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 580 KB | Output is correct |
2 | Correct | 3 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 380 KB | Output is correct |
2 | Correct | 4 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 2476 KB | Output is correct |
2 | Correct | 29 ms | 1716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 2668 KB | Output is correct |
2 | Correct | 26 ms | 2040 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 2424 KB | Output is correct |
2 | Correct | 44 ms | 2608 KB | Output is correct |