#include <bits/stdc++.h>
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
int n, m, d;
ll res;
multiset <int> s;
int main () {
FIO;
cin >> n >> m >> d;
for (int i = 0; i < n+m; i++) {
int x; cin >> x;
auto p = s.lower_bound(x);
if (!i);
else if (p == s.begin()) res += max(0, d-*p+x);
else if (p == s.end()) res += max(0, d-x+*(--p));
else {
int y = *p;
int z = *(--p);
res += max(0, d-x+y)+max(0, d-z+x)-max(0,d-z+y);
}
s.insert(x);
if (i >= n) {
cout << res/2;
if (res%2) cout << "." << res%2*5;
cout << " ";
}
}
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... |