# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
59819 |
2018-07-23T07:26:08 Z |
정원준(#1727) |
Sparklers (JOI17_sparklers) |
C++11 |
|
4 ms |
488 KB |
#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;
}
printf("%lld",bin(0,1000000001));
}
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]);
~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
412 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
488 KB |
Output is correct |
6 |
Correct |
3 ms |
488 KB |
Output is correct |
7 |
Incorrect |
3 ms |
488 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
412 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
488 KB |
Output is correct |
6 |
Correct |
3 ms |
488 KB |
Output is correct |
7 |
Incorrect |
3 ms |
488 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
412 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
488 KB |
Output is correct |
6 |
Correct |
3 ms |
488 KB |
Output is correct |
7 |
Incorrect |
3 ms |
488 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |