#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k;
ll x[100010];
bool dp[1010][1010];
inline bool able(ll s)
{
for(int i=0;i<n;i++)
dp[i][i]=i==k-1?1:0;
for(int l=1;l<n;l++)
{
for(int i=0;i+l<n;i++)
{
int j=i+l;
dp[i][j]=(dp[i+1][j]||dp[i][j-1])&&x[i]+s*l>=x[j]-s*l;
}
}
return dp[0][n-1];
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll t;
cin>>n>>k>>t;
for(int i=0;i<n;i++)
cin>>x[i];
ll s=0;
ll e=inf;
while(s<e)
{
ll m=s+e>>1;
if(able(m))
e=m;
else
s=m+1;
}
cout<<(s+t-1)/t<<endl;
return 0;
}
Compilation message
sparklers.cpp: In function 'int main()':
sparklers.cpp:46:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll m=s+e>>1;
~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
504 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
504 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
26 ms |
1028 KB |
Output is correct |
23 |
Correct |
15 ms |
888 KB |
Output is correct |
24 |
Correct |
21 ms |
1016 KB |
Output is correct |
25 |
Correct |
42 ms |
1528 KB |
Output is correct |
26 |
Correct |
37 ms |
1396 KB |
Output is correct |
27 |
Correct |
35 ms |
1400 KB |
Output is correct |
28 |
Correct |
36 ms |
1400 KB |
Output is correct |
29 |
Correct |
36 ms |
1400 KB |
Output is correct |
30 |
Correct |
33 ms |
1400 KB |
Output is correct |
31 |
Correct |
37 ms |
1400 KB |
Output is correct |
32 |
Correct |
36 ms |
1400 KB |
Output is correct |
33 |
Correct |
39 ms |
1272 KB |
Output is correct |
34 |
Correct |
37 ms |
1400 KB |
Output is correct |
35 |
Correct |
36 ms |
1400 KB |
Output is correct |
36 |
Correct |
40 ms |
1272 KB |
Output is correct |
37 |
Correct |
36 ms |
1400 KB |
Output is correct |
38 |
Correct |
35 ms |
1400 KB |
Output is correct |
39 |
Correct |
37 ms |
1400 KB |
Output is correct |
40 |
Correct |
34 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
504 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
26 ms |
1028 KB |
Output is correct |
23 |
Correct |
15 ms |
888 KB |
Output is correct |
24 |
Correct |
21 ms |
1016 KB |
Output is correct |
25 |
Correct |
42 ms |
1528 KB |
Output is correct |
26 |
Correct |
37 ms |
1396 KB |
Output is correct |
27 |
Correct |
35 ms |
1400 KB |
Output is correct |
28 |
Correct |
36 ms |
1400 KB |
Output is correct |
29 |
Correct |
36 ms |
1400 KB |
Output is correct |
30 |
Correct |
33 ms |
1400 KB |
Output is correct |
31 |
Correct |
37 ms |
1400 KB |
Output is correct |
32 |
Correct |
36 ms |
1400 KB |
Output is correct |
33 |
Correct |
39 ms |
1272 KB |
Output is correct |
34 |
Correct |
37 ms |
1400 KB |
Output is correct |
35 |
Correct |
36 ms |
1400 KB |
Output is correct |
36 |
Correct |
40 ms |
1272 KB |
Output is correct |
37 |
Correct |
36 ms |
1400 KB |
Output is correct |
38 |
Correct |
35 ms |
1400 KB |
Output is correct |
39 |
Correct |
37 ms |
1400 KB |
Output is correct |
40 |
Correct |
34 ms |
1400 KB |
Output is correct |
41 |
Runtime error |
19 ms |
4724 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
42 |
Halted |
0 ms |
0 KB |
- |