#include <bits/stdc++.h>
#define L long long
using namespace std;
L N,K,T;
L loc[100010];
L a[100010];
bool ok(L x){
L t=x*T*2;
//printf("%lld %lld\n",x,t);
L s=K,e=K,left=t;
while(s>1&&e<N)
{
//printf("%lld %lld %lld\n",s,e,left);
L t1=loc[s]-loc[s-1];
L t2=loc[e+1]-loc[e];
if(t1<t2)
{
if(t1>left) return 0;
left=left-t1+t;
s--;
}
else
{
if(t2>left) return 0;
left=left-t2+t;
e++;
}
}
while(s>1)
{
//printf("%lld %lld %lld\n",s,e,left);
L t1=loc[s]-loc[s-1];
if(t1>left) return 0;
left=left-t1+t;
s--;
}
while(e<N)
{
//printf("%lld %lld %lld\n",s,e,left);
L t2=loc[e+1]-loc[e];
if(t2>left) return 0;
left=left-t2+t;
e++;
}
return 1;
}
L bin(L s,L e){
if(s==e) return s;
L mid=(s+e)/2;
if(ok(mid)) return bin(s,mid);
else return bin(mid+1,e);
}
int main()
{
scanf("%lld %lld %lld",&N,&K,&T);
L i,st;
for(i=1;i<=N;i++)
{
scanf("%lld",&loc[i]);
}
st=loc[K];
for(i=1;i<=N;i++)
{
loc[i]-=st;
}
L temp=bin(0,1000000001);
if(temp==1000000001) while(1);
printf("%lld",temp);
}
Compilation message
sparklers.cpp: In function 'int main()':
sparklers.cpp:61:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld",&N,&K,&T);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:65:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&loc[i]);
~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
3 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
500 KB |
Output is correct |
6 |
Correct |
3 ms |
500 KB |
Output is correct |
7 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
3 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
500 KB |
Output is correct |
6 |
Correct |
3 ms |
500 KB |
Output is correct |
7 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
3 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
500 KB |
Output is correct |
6 |
Correct |
3 ms |
500 KB |
Output is correct |
7 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |