#include <bits/stdc++.h>
using namespace std;
long long solve(vector<int> coords, int D) {
sort(coords.begin(), coords.end());
long long x = coords[0];
long long cost = 0;
cout << "0\n";
for(int i = 1; i < coords.size(); i++) {
long long a = coords[i];
//cout << "\t" << x << " " << cost << " " << a << "\n";
if(a + cost - x >= D) {
// move new as much left as possible without increasing cost
x = max(x + D, a - cost);
}
else {
// moving new right, increasing cost
long long costinc = (D - (a + cost - x)) / 2;
// cout << "\t" << costinc << " ";
cost += costinc;
x = a + cost;
// cout << "\n";
}
cout << cost / 2;
if(cost & 0x1) {
cout << ".5";
}
cout << "\n";
}
return cost;
}
int main() {
int N, M, D;
cin >> N >> M >> D;
vector<int> coordinates;
for(int i = 0; i < N; i++) {
int a;
cin >> a;
coordinates.push_back(2 * a);
}
for(int i = 0; i < M; i++) {
int a;
cin >> a;
coordinates.push_back(2 * a);
}
long long b = solve(coordinates, 2 * D);
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... |