#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
int n, m, d;
vector<int> a, b;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> d;
if (m <= 10) {
a.resize(n); b.resize(m);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
for (int i = 0; i < m; i++) {
cin >> b[i];
a.push_back(b[i]);
sort(a.begin(), a.end());
long double e = a[0], ans = 0.0;
for (int j = 1; j < (int) a.size(); j++) {
long double reach = a[j] + ans;
if (reach - e > d) {
if (a[j] > e + d) e = max(e + d, a[j] - ans);
else e += d;
} else {
long double tmp = ans;
ans += (e + d - reach) / 2;
e = a[j] + tmp + (e + d - reach) / 2;
}
}
if (abs(ans - floor(ans)) < eps) cout << (long long) floor(ans) << ' ';
else cout << fixed << setprecision(1) << ans << ' ';
}
cout << '\n';
} else {
a.resize(m); b.resize(m);
cin >> a[0];
cout << 0 << ' ';
long double e = a[0], ans = 0.0;
for (int j = 1; j < m; j++) {
cin >> a[j];
long double reach = a[j] + ans;
if (reach - e > d) {
if (a[j] > e + d) e = max(e + d, a[j] - ans);
else e += d;
} else {
long double tmp = ans;
ans += (e + d - reach) / 2;
e = a[j] + tmp + (e + d - reach) / 2;
}
if (abs(ans - floor(ans)) < eps) cout << (long long) floor(ans) << ' ';
else cout << fixed << setprecision(1) << ans << ' ';
}
cout << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
121 ms |
1880 KB |
Output is correct |
10 |
Correct |
169 ms |
1892 KB |
Output is correct |
11 |
Correct |
61 ms |
1876 KB |
Output is correct |
12 |
Correct |
182 ms |
1864 KB |
Output is correct |
13 |
Correct |
55 ms |
1876 KB |
Output is correct |
14 |
Correct |
110 ms |
1884 KB |
Output is correct |
15 |
Correct |
119 ms |
1864 KB |
Output is correct |
16 |
Correct |
58 ms |
1884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
4492 KB |
Output is correct |
2 |
Correct |
87 ms |
6740 KB |
Output is correct |
3 |
Correct |
85 ms |
6720 KB |
Output is correct |
4 |
Correct |
34 ms |
4560 KB |
Output is correct |
5 |
Correct |
59 ms |
5812 KB |
Output is correct |
6 |
Correct |
63 ms |
4924 KB |
Output is correct |
7 |
Correct |
106 ms |
5864 KB |
Output is correct |
8 |
Correct |
75 ms |
4656 KB |
Output is correct |
9 |
Correct |
105 ms |
4520 KB |
Output is correct |
10 |
Correct |
91 ms |
7004 KB |
Output is correct |
11 |
Correct |
106 ms |
5352 KB |
Output is correct |
12 |
Correct |
97 ms |
6308 KB |
Output is correct |
13 |
Correct |
78 ms |
4596 KB |
Output is correct |
14 |
Correct |
62 ms |
6568 KB |
Output is correct |
15 |
Correct |
97 ms |
6320 KB |
Output is correct |
16 |
Correct |
77 ms |
4172 KB |
Output is correct |
17 |
Correct |
58 ms |
5860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
4492 KB |
Output is correct |
2 |
Correct |
87 ms |
6740 KB |
Output is correct |
3 |
Correct |
85 ms |
6720 KB |
Output is correct |
4 |
Correct |
34 ms |
4560 KB |
Output is correct |
5 |
Correct |
59 ms |
5812 KB |
Output is correct |
6 |
Correct |
63 ms |
4924 KB |
Output is correct |
7 |
Correct |
106 ms |
5864 KB |
Output is correct |
8 |
Correct |
75 ms |
4656 KB |
Output is correct |
9 |
Correct |
105 ms |
4520 KB |
Output is correct |
10 |
Correct |
91 ms |
7004 KB |
Output is correct |
11 |
Correct |
106 ms |
5352 KB |
Output is correct |
12 |
Correct |
97 ms |
6308 KB |
Output is correct |
13 |
Correct |
78 ms |
4596 KB |
Output is correct |
14 |
Correct |
62 ms |
6568 KB |
Output is correct |
15 |
Correct |
97 ms |
6320 KB |
Output is correct |
16 |
Correct |
77 ms |
4172 KB |
Output is correct |
17 |
Correct |
58 ms |
5860 KB |
Output is correct |
18 |
Incorrect |
88 ms |
5988 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |