# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1179305 | CodeLakVN | Cipele (COCI18_cipele) | C++20 | 29 ms | 1096 KiB |
#include <bits/stdc++.h>
using namespace std;
#define task "18_cipele"
#define no "NO"
#define yes "YES"
#define F first
#define S second
#define vec vector
#define _mp make_pair
#define ii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define evoid(val) return void(std::cout << val)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FOD(i, b, a) for(int i = (b); i >= (a); --i)
const int MAX_N = (int)1e5 + 5;
int n, m;
vector<int> a, b;
bool valid(int val) {
int j = 1;
FOR(i, 1, n) {
while (j <= m && abs(b[j] - a[i]) > val) j++;
if (j > m) return false;
j++;
}
return true;
}
int bs(int lo, int hi) {
int res = -1;
while (lo <= hi) {
int mid = (lo + hi) >> 1;
if (valid(mid)) hi = (res = mid) - 1;
else lo = mid + 1;
}
return res;
}
void solve() {
cin >> n >> m;
a.resize(n + 1);
b.resize(m + 1);
FOR(i, 1, n) cin >> a[i];
FOR(i, 1, m) cin >> b[i];
if (n > m) swap(a, b), swap(n, m);
sort(all(a));
sort(all(b));
cout << bs(0, (int)1e9) << "\n";
}
int32_t main() {
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
bool multitest = 0;
int numTest = 1;
if (multitest) cin >> numTest;
while (numTest--) {
solve();
}
return 0;
}
/* Lak lu theo dieu nhac!!!! */
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |