| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1327176 | asim | Cipele (COCI18_cipele) | C++20 | 64 ms | 9712 KiB |
// created : 2026/02/21 21:27:49
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(v) v.begin(), v.end()
void solve() {
int n, m; cin >> n >> m;
multiset<int> st, st2;
for(int i = 0; i < n; i++) {
int x; cin >> x;
st.insert(x);
}
for(int i = 0; i < m; i++) {
int x; cin >> x;
st2.insert(x);
}
int maxi = -4e18;
if(n > m) {
for(auto &x : st2) {
auto it = st.lower_bound(x);
if(it == st.end()) {
it--;
maxi = max(maxi, abs(*it - x));
st.erase(it);
}
else if(it == st.begin()) {
maxi = max(maxi, abs(*it - x));
st.erase(it);
}
else {
int b = *it;
it--;
int a = *it;
if(abs(a - x) > abs(b - x)) {
maxi = max(maxi, abs(b - x));
it++;
st.erase(it);
}
else {
maxi = max(maxi, abs(a - x));
st.erase(it);
}
}
}
}
else {
for(auto &x : st) {
auto it = st2.lower_bound(x);
if(it == st2.end()) {
it--;
maxi = max(maxi, abs(*it - x));
st2.erase(it);
}
else if(it == st2.begin()) {
maxi = max(maxi, abs(*it - x));
st2.erase(it);
}
else {
int b = *it;
it--;
int a = *it;
if(abs(a - x) > abs(b - x)) {
maxi = max(maxi, abs(b - x));
it++;
st2.erase(it);
}
else {
maxi = max(maxi, abs(a - x));
st2.erase(it);
}
}
}
}
cout << maxi << '\n';
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
}| # | 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... | ||||
