Submission #891380

#TimeUsernameProblemLanguageResultExecution timeMemory
891380StefanSebezSparklers (JOI17_sparklers)C++14
0 / 100
1 ms348 KiB
#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)

sparklers.cpp: In function 'int main()':
sparklers.cpp:6:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     int n,K,T;scanf("%i%i%i",&n,&K,&T);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~
sparklers.cpp:7:41: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     ll x[n+1];for(int i=1;i<=n;i++)scanf("%lld",&x[i]);
      |                                    ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...