# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
891380 | StefanSebez | Sparklers (JOI17_sparklers) | C++14 | 1 ms | 348 KiB |
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;
#define ll long long
int main()
{
int n,K,T;scanf("%i%i%i",&n,&K,&T);
ll x[n+1];for(int i=1;i<=n;i++)scanf("%lld",&x[i]);
int l=1,r=1e9,res;
while(l<=r)
{
long long mid=(l+r)/2;
int i=K-1,j=K+1;
long double t=0,X=x[K],ct=0;
bool bul=true;
while(1<=i || j<=n)
{
ct++;
if(1<=i && (X-(x[i]+t*mid))<=2*(ct*T-t)*mid)
{
long double t2=t;
t+=(X-(x[i]+t*mid))/(2*mid);
X=(X+(x[i]+t2*mid))/2;
i--;
continue;
}
if(j<=n && ((x[j]-t*mid)-X)<=2*(ct*T-t)*mid)
{
long double t2=t;
t+=((x[j]-t*mid)-X)/(2*mid);
X=((x[j]-t2*mid)+X)/2;
j++;
continue;
}
bul=false;
break;
}
if(bul)
{
r=mid-1;
res=mid;
}
else l=mid+1;
}
printf("%i\n",res);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |