# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115523 | 2024-11-20T14:53:08 Z | duytuandao21 | Cipele (COCI18_cipele) | C++17 | 1000 ms | 2924 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 7; const int infll = 1e18 + 7; typedef pair<int, int> pii; int n, m; vector<int> a; vector<int> b; bool check(int k) { // int j = 0; // int cnt = 0; // for (auto &x : a) { // while (j < b.size() && abs(b[j] - x) > k) ++j; // if (j < b.size() && abs(b[j] - x) <= k) { // // cout << j << ' ' ; // ++cnt; // ++j; // } // } // if (cnt == a.size()) return true; vector<int> mark((int)b.size() + 1, 0); int cnt = 0; for (auto &x : a) { for (int j = 0; j < b.size(); j++) { if (mark[j] == 0 && abs(b[j] - x) <= k) { ++cnt; mark[j] = 1; break; } } } if (cnt == a.size()) return true; return false; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { int x; cin >> x; a.push_back(x); } for (int i = 1; i <= m; i++) { int x; cin >> x; b.push_back(x); } if (a.size() > b.size()) swap(a, b); sort(a.begin(), a.end()); sort(b.begin(), b.end()); int l = 0, r = 1e9 + 7; int res = -1; while (l <= r) { int mid = (l + r) / 2; if (check(mid)) { res = mid; r = mid - 1; } else l = mid + 1; } cout << res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1067 ms | 2896 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1063 ms | 2924 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 75 ms | 336 KB | Output is correct |
2 | Correct | 276 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 336 KB | Output is correct |
2 | Correct | 284 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 173 ms | 592 KB | Output is correct |
2 | Correct | 272 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 179 ms | 592 KB | Output is correct |
2 | Correct | 298 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 230 ms | 760 KB | Output is correct |
2 | Correct | 282 ms | 696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1062 ms | 2508 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1032 ms | 2632 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1066 ms | 2508 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |