This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, D;
cin >> n >> m >> D;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
vector<int> b(m);
for (int i = 0; i < m; ++i) {
cin >> b[i];
}
if (n > 0) {
sort(a.begin(), a.end());
for (int i = 0; i < m; ++i) {
a.insert(lower_bound(a.begin(), a.end(), b[i]), b[i]);
ll ans = numeric_limits<ll>::min(), mx = numeric_limits<ll>::min();
for (int k = size(a) - 1; k >= 0; --k) {
mx = max(mx, 1LL * D * k - a[k]);
ans = max(ans, mx - 1LL * D * k + a[k]);
}
if (ans % 2 == 0) {
cout << ans / 2 << ' ';
} else {
cout << ans / 2 << ".5 ";
}
}
} else {
assert(false);
}
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... |