This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int n,m,d,a,ans=0,l,r;
double chng;
multiset<int> ms;
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
cin >> n >> m >> d;
for(int i=1;i<=n+m;i++)
{
cin >> a;
if(ms.size()==0)
{
ms.insert(a);
chng=ans/2;
if(i>n)
{
if(floor(chng)==chng)
{
printf("%.0f ",chng);
}else
{
printf("%.1f ",chng);
}
}
continue;
}
auto it=ms.lower_bound(a);
if(it==ms.end())
{
--it;
ans+=(d-(a-(*it)));
}else if(it==ms.begin())
{
ans+=(d-((*it)-a));
}else
{
r=(*it);
--it;
l=(*it);
ans-=(d-(r-l));
ans+=(d-(a-l));
ans+=(d-(r-a));
}
ms.insert(a);
chng=(double)ans/2;
if(i>n)
{
if(floor(chng)==chng)
{
printf("%.0f ",chng);
}else
{
printf("%.1f ",chng);
}
}
}
}
# | 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... |