#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef vector<int> vi;
#define F first
#define S second
#define pb push_back
const int MN = 1005;
int N, K, T, i, j, lo, hi, mid, arr[MN];
double dp[MN][MN]; bitset<MN> vs[MN];
double solve(int l,int r){
if(vs[l][r]) return dp[l][r];
else if(l==r){
if(l==K) return T;
else return -1;
}
vs[l][r]=1;
dp[l][r]=-1;
if(solve(l,r-1)>=(arr[r]-arr[r-1])/(double)(2*mid))
dp[l][r]=max(dp[l][r],solve(l,r-1)-(arr[r]-arr[r-1])/(double)(2*mid)+T);
if(solve(l+1,r)>=(arr[l+1]-arr[l])/(double)(2*mid))
dp[l][r]=max(dp[l][r],solve(l+1,r)-(arr[l+1]-arr[l])/(double)(2*mid)+T);
return dp[l][r];
}
int main(){
scanf("%d%d%d",&N,&K,&T);
for(i=1;i<=N;i++)
scanf("%d",&arr[i]);
if(arr[N]==0){
printf("0\n");
return 0;
}
lo = 1, hi = 1e9;
while(lo<hi){
mid = (lo+hi)>>1;
for(i=1;i<=N;i++)
vs[i].reset();
if(solve(1,N)>=0) hi=mid;
else lo=mid+1;
}
printf("%d\n",lo);
return 0;
}
Compilation message
sparklers.cpp: In function 'int main()':
sparklers.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d",&N,&K,&T);
~~~~~^~~~~~~~~~~~~~~~~~~
sparklers.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&arr[i]);
~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
168 ms |
5368 KB |
Output is correct |
23 |
Correct |
93 ms |
4088 KB |
Output is correct |
24 |
Correct |
126 ms |
5248 KB |
Output is correct |
25 |
Correct |
224 ms |
7544 KB |
Output is correct |
26 |
Correct |
263 ms |
7424 KB |
Output is correct |
27 |
Correct |
285 ms |
7424 KB |
Output is correct |
28 |
Correct |
293 ms |
7500 KB |
Output is correct |
29 |
Correct |
272 ms |
7424 KB |
Output is correct |
30 |
Correct |
266 ms |
7496 KB |
Output is correct |
31 |
Correct |
283 ms |
7544 KB |
Output is correct |
32 |
Correct |
278 ms |
7424 KB |
Output is correct |
33 |
Correct |
304 ms |
7544 KB |
Output is correct |
34 |
Correct |
284 ms |
7544 KB |
Output is correct |
35 |
Correct |
285 ms |
7544 KB |
Output is correct |
36 |
Correct |
254 ms |
7544 KB |
Output is correct |
37 |
Correct |
242 ms |
7544 KB |
Output is correct |
38 |
Correct |
280 ms |
7424 KB |
Output is correct |
39 |
Correct |
230 ms |
7544 KB |
Output is correct |
40 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
168 ms |
5368 KB |
Output is correct |
23 |
Correct |
93 ms |
4088 KB |
Output is correct |
24 |
Correct |
126 ms |
5248 KB |
Output is correct |
25 |
Correct |
224 ms |
7544 KB |
Output is correct |
26 |
Correct |
263 ms |
7424 KB |
Output is correct |
27 |
Correct |
285 ms |
7424 KB |
Output is correct |
28 |
Correct |
293 ms |
7500 KB |
Output is correct |
29 |
Correct |
272 ms |
7424 KB |
Output is correct |
30 |
Correct |
266 ms |
7496 KB |
Output is correct |
31 |
Correct |
283 ms |
7544 KB |
Output is correct |
32 |
Correct |
278 ms |
7424 KB |
Output is correct |
33 |
Correct |
304 ms |
7544 KB |
Output is correct |
34 |
Correct |
284 ms |
7544 KB |
Output is correct |
35 |
Correct |
285 ms |
7544 KB |
Output is correct |
36 |
Correct |
254 ms |
7544 KB |
Output is correct |
37 |
Correct |
242 ms |
7544 KB |
Output is correct |
38 |
Correct |
280 ms |
7424 KB |
Output is correct |
39 |
Correct |
230 ms |
7544 KB |
Output is correct |
40 |
Correct |
5 ms |
384 KB |
Output is correct |
41 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
42 |
Halted |
0 ms |
0 KB |
- |