General

# Author Problem Lang Verdict Time Memory Sent Judged
94326719 Contestant:
AM_I_Learning
1408C - 27 GNU C++14 Accepted 77 ms 1576 KB 2020-09-30 18:45:17 2020-09-30 20:37:17

→ Source
//Jai Sai Ram
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
ll a[200001];
ll N;
double find_pointa(double tim)
{
double speed=1.0;
double pos=0;
double ti=0;
for(ll i=0;i<N;i++)
{
double diff=abs(a[i]-pos);
double t=diff/speed;
if(ti+t>tim)
{
pos+=((tim-ti)*speed);
return pos;
}
else
{
pos=a[i];
ti+=t;
}
speed+=1;
}
pos+=((tim-ti)*speed);
return pos;
return pos;
}
double find_pointb(double tim, double pos)
{
double speed=1.0;
double ti=0;
for(ll i=N-1;i>=0;i--)
{
double diff=abs(a[i]-pos);
double t=diff/speed;
if(ti+t>tim)
{
pos-=((tim-ti)*speed);
return pos;
}
else
{
pos=a[i];
ti+=t;
}
speed+=1;
}
pos-=((tim-ti)*speed);
return pos;
return pos;
}
void solve()
{
ll i,j,k,l,m,n,o;
cin>>n>>l;
N=n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
ll start=0,end=1000000000;
ll mid,ans;
// cout<<find_pointa(3.80000000)<<" "<<find_pointb(3.80000000,l)<<endl;
while(start<=end)
{
mid=(start+end)/2;
double x=find_pointa(mid);
double y=find_pointb(mid,l);
if(x>=y)
{
//met;
ans=mid;
end=mid-1;
}
else
{
start=mid+1;
}
}
start=0,end=1000000000;
ll num,den=end;
ll ann;
ans--;
while(start<=end)
{
mid=(start+end)/2;
double xx,d;
xx=mid;
d=ans+xx/den;
//cout<<d<<endl;
double x=find_pointa(d);
double y=find_pointb(d,l);
if(x>=y)
{
//met;
ann=mid;
end=mid-1;
}
else
{
start=mid+1;
}
}
double x=(ans*den+ann);
x/=den;
cout<<fixed<<setprecision(10)<<x<<endl;
}
int main()
{
ll t=1;
ios_base::sync_with_stdio(false);
cin.tie(0);
ll i=1;
cin>>t;
while(t--)
{

solve();
i++;
}
return 0;
}


?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
?
?
?