이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
constexpr int inf = 1e9;
constexpr int epsilon = 1;
int d;
bool ok(vector<int> &arr, int move) {
int lastPos = -inf;
for (auto x : arr) {
int req = (lastPos + d) - x;
req = max(req, -move);
if (req > move) return false;
lastPos = x + req;
}
return true;
}
double solve(vector<int> arr) {
std::sort(arr.begin(), arr.end());
int l = 0, r = inf;
while (r - l > 0) {
int mid = l + (r - l) / 2;
if (ok(arr,mid)) {
r = mid;
} else {
l = mid + epsilon;
}
}
return l;
}
int main() {
int n, m; cin >> n >> m >> d;
vector<int> p;
for (int i = 0; i < n; ++i) {
int x; cin >> x;
x *= 2;
p.push_back(x);
}
d*=2;
for (int i = 0; i < m; ++i) {
int x; cin >> x;
x *= 2;
p.push_back(x);
int ans = solve(p);
cout << ans / 2 << (ans % 2 ? ".5" : "") << " ";
}
return 0;
}
# | 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... |