#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
using pii = pair<int, int>;
#define fr first
#define sc second
signed main() {
int n, m, d;
cin >> n >> m >> d;
swap(m, n);
n += m;
vector<pii> a, asort;
vector<int> pos(n + 1);
asort.push_back({0, 0});
a.push_back({0, 0});
for (int i = 1; i <= n; i ++) {
int x;
cin >> x;
a.push_back({x, i});
asort.push_back({x, i});
}
sort(asort.begin(), asort.end());
for (int i = 1; i <= n; i ++)
pos[asort[i].sc] = i;
int ans = 0;
for (int i = 1; i <= n; i ++) {
for (int j = 1; j <= n; j ++) {
if (pos[i] == j)
break;
if (asort[j].sc < i)
ans = max(ans, (pos[i] - j) * d - (a[i].fr - asort[j].fr));
}
if (i > m) {
cout << ans / 2;
if (ans % 2 == 1)
cout << ".5";
cout << " ";
}
}
cout << '\n';
}
/*
ans = max(i<j)(1/2*((j - i) * d - (aj - ai)));
cred
*/
# | 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... |