#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void print_ans(ll ans) {
cout << ans/2;
if (ans & 1) cout << ".5";
cout << ' ';
}
void solve() {
ll n, m, d;
cin >> n >> m >> d;
if (m <= 10) {
d *= 2;
vector<ll> v(n);
for (ll &i : v) {
cin >> i;
i *= 2;
}
for (int i = 0; i < m; ++i) {
ll u;
cin >> u;
v.push_back(2*u);
sort(v.begin(), v.end());
ll l = -1, r = 1e15;
while (r-l > 1) {
ll md = (l + r) / 2;
ll pp = -1e18;
bool g = 1;
for (int j : v) {
ll pos = max(j - md, pp + d);
g &= pos <= j + md;
pp = pos;
}
if (g) r = md;
else l = md;
}
print_ans(r);
}
} else {
ll ans = 0;
ll minv = 1e18;
for (int i = 0; i < m; ++i) {
ll v;
cin >> v;
v = d * i - v;
minv = min(minv, v);
ans = max(ans, v - minv);
print_ans(ans);
}
}
cout << '\n';
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
1012 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
1012 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
223 ms |
6748 KB |
Output is correct |
10 |
Correct |
267 ms |
5464 KB |
Output is correct |
11 |
Correct |
169 ms |
5968 KB |
Output is correct |
12 |
Correct |
273 ms |
6232 KB |
Output is correct |
13 |
Correct |
164 ms |
6488 KB |
Output is correct |
14 |
Correct |
228 ms |
5996 KB |
Output is correct |
15 |
Correct |
211 ms |
5208 KB |
Output is correct |
16 |
Correct |
168 ms |
5468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
1368 KB |
Output is correct |
2 |
Correct |
32 ms |
3288 KB |
Output is correct |
3 |
Correct |
31 ms |
3156 KB |
Output is correct |
4 |
Correct |
26 ms |
1052 KB |
Output is correct |
5 |
Correct |
29 ms |
2388 KB |
Output is correct |
6 |
Correct |
27 ms |
1584 KB |
Output is correct |
7 |
Correct |
31 ms |
2384 KB |
Output is correct |
8 |
Correct |
27 ms |
1116 KB |
Output is correct |
9 |
Correct |
28 ms |
1180 KB |
Output is correct |
10 |
Correct |
32 ms |
3420 KB |
Output is correct |
11 |
Correct |
29 ms |
1884 KB |
Output is correct |
12 |
Correct |
31 ms |
2900 KB |
Output is correct |
13 |
Correct |
29 ms |
2388 KB |
Output is correct |
14 |
Correct |
31 ms |
4432 KB |
Output is correct |
15 |
Correct |
52 ms |
4180 KB |
Output is correct |
16 |
Correct |
27 ms |
2140 KB |
Output is correct |
17 |
Correct |
30 ms |
3668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
1368 KB |
Output is correct |
2 |
Correct |
32 ms |
3288 KB |
Output is correct |
3 |
Correct |
31 ms |
3156 KB |
Output is correct |
4 |
Correct |
26 ms |
1052 KB |
Output is correct |
5 |
Correct |
29 ms |
2388 KB |
Output is correct |
6 |
Correct |
27 ms |
1584 KB |
Output is correct |
7 |
Correct |
31 ms |
2384 KB |
Output is correct |
8 |
Correct |
27 ms |
1116 KB |
Output is correct |
9 |
Correct |
28 ms |
1180 KB |
Output is correct |
10 |
Correct |
32 ms |
3420 KB |
Output is correct |
11 |
Correct |
29 ms |
1884 KB |
Output is correct |
12 |
Correct |
31 ms |
2900 KB |
Output is correct |
13 |
Correct |
29 ms |
2388 KB |
Output is correct |
14 |
Correct |
31 ms |
4432 KB |
Output is correct |
15 |
Correct |
52 ms |
4180 KB |
Output is correct |
16 |
Correct |
27 ms |
2140 KB |
Output is correct |
17 |
Correct |
30 ms |
3668 KB |
Output is correct |
18 |
Incorrect |
31 ms |
3932 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |