#include<bits/stdc++.h>
using namespace std;
const long double N=999999999.0;
int a,b,c,d,e,i,j,ii,jj,zx,xc,K,I,IA;
pair <long double, long double> p[509];
long double A,B,C,D,dp[509][509],dp2[509][509],pas=N;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>K;
for(i=1; i<=a; i++){
cin>>p[i].second>>p[i].first;
if(p[i].first==-1) p[i].first=N;
}
sort(p+1,p+a+1);
for(i=1; i<=a; i++) if(p[i].first==N) p[i].first=-1;
for(i=1; i<=a; i++) swap(p[i].first,p[i].second);
for(i=0; i<=a+1; i++){
for(j=0; j<=a+1; j++) dp2[i][j]=N;
}
dp2[a+1][0]=0;
for(i=a; i>=1; i--){
for(j=0; j<=a; j++){
dp2[i][j]=dp2[i+1][j];
if(j>0) dp2[i][j]=min(dp2[i][j],dp2[i+1][j-1]+p[i].first);
}
}
for(jj=0; jj<=K; jj++){
for(i=0; i<=K; i++){
I=min(i,K);
for(j=0; j<=i; j++){
dp[i][j]=N;
}
}
dp[0][0]=0;
for(i=1; i<=K; i++){
for(j=0; j<=i; j++){
if(j<i){
A=dp[i-1][j]+p[i].first/(jj+1.0);
if(dp[i][j]>A) dp[i][j]=A;
}
if(j!=0&&p[i].second!=-1){
A=dp[i-1][j-1]+p[i].second/j;
if(dp[i][j]>A) dp[i][j]=A;
}
/*if(j==jj){
A=dp[i][j]+dp2[i+1][K-i]/(jj+1.0);
if(pas>A) pas=A;
}*/
}
}
for(i=jj; i<=K; i++){
A=dp[i][jj]+dp2[i+1][K-i]/(jj+1.0);
if(pas>A) pas=A;
}
}
cout<<setprecision(12)<<pas;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
7 ms |
4616 KB |
Output is correct |
6 |
Correct |
20 ms |
4872 KB |
Output is correct |
7 |
Correct |
114 ms |
5844 KB |
Output is correct |
8 |
Correct |
350 ms |
6836 KB |
Output is correct |
9 |
Correct |
827 ms |
7832 KB |
Output is correct |
10 |
Correct |
289 ms |
6636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
7 ms |
4616 KB |
Output is correct |
6 |
Correct |
20 ms |
4872 KB |
Output is correct |
7 |
Correct |
114 ms |
5844 KB |
Output is correct |
8 |
Correct |
350 ms |
6836 KB |
Output is correct |
9 |
Correct |
827 ms |
7832 KB |
Output is correct |
10 |
Correct |
289 ms |
6636 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
37 ms |
5064 KB |
Output is correct |
13 |
Correct |
37 ms |
5076 KB |
Output is correct |
14 |
Correct |
32 ms |
5156 KB |
Output is correct |
15 |
Correct |
418 ms |
6632 KB |
Output is correct |
16 |
Correct |
373 ms |
6612 KB |
Output is correct |
17 |
Correct |
303 ms |
6612 KB |
Output is correct |
18 |
Correct |
1142 ms |
7824 KB |
Output is correct |
19 |
Correct |
966 ms |
7832 KB |
Output is correct |
20 |
Correct |
863 ms |
7828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
456 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
452 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
456 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
456 KB |
Output is correct |
35 |
Correct |
1 ms |
468 KB |
Output is correct |
36 |
Correct |
1 ms |
452 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
1 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Correct |
1 ms |
456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
456 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
452 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
456 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
456 KB |
Output is correct |
35 |
Correct |
1 ms |
468 KB |
Output is correct |
36 |
Correct |
1 ms |
452 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
1 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Correct |
1 ms |
456 KB |
Output is correct |
41 |
Correct |
1 ms |
852 KB |
Output is correct |
42 |
Correct |
1 ms |
840 KB |
Output is correct |
43 |
Correct |
1 ms |
980 KB |
Output is correct |
44 |
Correct |
1 ms |
980 KB |
Output is correct |
45 |
Correct |
2 ms |
1108 KB |
Output is correct |
46 |
Correct |
2 ms |
1108 KB |
Output is correct |
47 |
Correct |
5 ms |
1108 KB |
Output is correct |
48 |
Correct |
4 ms |
1220 KB |
Output is correct |
49 |
Correct |
6 ms |
1228 KB |
Output is correct |
50 |
Correct |
6 ms |
1220 KB |
Output is correct |
51 |
Correct |
11 ms |
1364 KB |
Output is correct |
52 |
Correct |
10 ms |
1352 KB |
Output is correct |
53 |
Correct |
4 ms |
1108 KB |
Output is correct |
54 |
Correct |
4 ms |
1108 KB |
Output is correct |
55 |
Correct |
4 ms |
1108 KB |
Output is correct |
56 |
Correct |
4 ms |
1220 KB |
Output is correct |
57 |
Correct |
4 ms |
1108 KB |
Output is correct |
58 |
Correct |
4 ms |
1108 KB |
Output is correct |
59 |
Correct |
4 ms |
1108 KB |
Output is correct |
60 |
Correct |
4 ms |
1224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1144 ms |
7832 KB |
Output is correct |
2 |
Correct |
1108 ms |
7872 KB |
Output is correct |
3 |
Correct |
1123 ms |
7824 KB |
Output is correct |
4 |
Correct |
1117 ms |
7828 KB |
Output is correct |
5 |
Correct |
1132 ms |
7828 KB |
Output is correct |
6 |
Correct |
1103 ms |
7828 KB |
Output is correct |
7 |
Correct |
1189 ms |
7832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
7 ms |
4616 KB |
Output is correct |
6 |
Correct |
20 ms |
4872 KB |
Output is correct |
7 |
Correct |
114 ms |
5844 KB |
Output is correct |
8 |
Correct |
350 ms |
6836 KB |
Output is correct |
9 |
Correct |
827 ms |
7832 KB |
Output is correct |
10 |
Correct |
289 ms |
6636 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
37 ms |
5064 KB |
Output is correct |
13 |
Correct |
37 ms |
5076 KB |
Output is correct |
14 |
Correct |
32 ms |
5156 KB |
Output is correct |
15 |
Correct |
418 ms |
6632 KB |
Output is correct |
16 |
Correct |
373 ms |
6612 KB |
Output is correct |
17 |
Correct |
303 ms |
6612 KB |
Output is correct |
18 |
Correct |
1142 ms |
7824 KB |
Output is correct |
19 |
Correct |
966 ms |
7832 KB |
Output is correct |
20 |
Correct |
863 ms |
7828 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
328 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
332 KB |
Output is correct |
35 |
Correct |
1 ms |
324 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
456 KB |
Output is correct |
38 |
Correct |
1 ms |
340 KB |
Output is correct |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Correct |
1 ms |
468 KB |
Output is correct |
41 |
Correct |
1 ms |
468 KB |
Output is correct |
42 |
Correct |
1 ms |
468 KB |
Output is correct |
43 |
Correct |
1 ms |
468 KB |
Output is correct |
44 |
Correct |
1 ms |
468 KB |
Output is correct |
45 |
Correct |
1 ms |
468 KB |
Output is correct |
46 |
Correct |
1 ms |
468 KB |
Output is correct |
47 |
Correct |
1 ms |
452 KB |
Output is correct |
48 |
Correct |
1 ms |
468 KB |
Output is correct |
49 |
Correct |
1 ms |
456 KB |
Output is correct |
50 |
Correct |
1 ms |
468 KB |
Output is correct |
51 |
Correct |
1 ms |
468 KB |
Output is correct |
52 |
Correct |
1 ms |
468 KB |
Output is correct |
53 |
Correct |
1 ms |
468 KB |
Output is correct |
54 |
Correct |
1 ms |
456 KB |
Output is correct |
55 |
Correct |
1 ms |
468 KB |
Output is correct |
56 |
Correct |
1 ms |
452 KB |
Output is correct |
57 |
Correct |
1 ms |
468 KB |
Output is correct |
58 |
Correct |
1 ms |
468 KB |
Output is correct |
59 |
Correct |
1 ms |
468 KB |
Output is correct |
60 |
Correct |
1 ms |
456 KB |
Output is correct |
61 |
Correct |
1 ms |
852 KB |
Output is correct |
62 |
Correct |
1 ms |
840 KB |
Output is correct |
63 |
Correct |
1 ms |
980 KB |
Output is correct |
64 |
Correct |
1 ms |
980 KB |
Output is correct |
65 |
Correct |
2 ms |
1108 KB |
Output is correct |
66 |
Correct |
2 ms |
1108 KB |
Output is correct |
67 |
Correct |
5 ms |
1108 KB |
Output is correct |
68 |
Correct |
4 ms |
1220 KB |
Output is correct |
69 |
Correct |
6 ms |
1228 KB |
Output is correct |
70 |
Correct |
6 ms |
1220 KB |
Output is correct |
71 |
Correct |
11 ms |
1364 KB |
Output is correct |
72 |
Correct |
10 ms |
1352 KB |
Output is correct |
73 |
Correct |
4 ms |
1108 KB |
Output is correct |
74 |
Correct |
4 ms |
1108 KB |
Output is correct |
75 |
Correct |
4 ms |
1108 KB |
Output is correct |
76 |
Correct |
4 ms |
1220 KB |
Output is correct |
77 |
Correct |
4 ms |
1108 KB |
Output is correct |
78 |
Correct |
4 ms |
1108 KB |
Output is correct |
79 |
Correct |
4 ms |
1108 KB |
Output is correct |
80 |
Correct |
4 ms |
1224 KB |
Output is correct |
81 |
Correct |
1144 ms |
7832 KB |
Output is correct |
82 |
Correct |
1108 ms |
7872 KB |
Output is correct |
83 |
Correct |
1123 ms |
7824 KB |
Output is correct |
84 |
Correct |
1117 ms |
7828 KB |
Output is correct |
85 |
Correct |
1132 ms |
7828 KB |
Output is correct |
86 |
Correct |
1103 ms |
7828 KB |
Output is correct |
87 |
Correct |
1189 ms |
7832 KB |
Output is correct |
88 |
Correct |
7 ms |
4564 KB |
Output is correct |
89 |
Correct |
7 ms |
4608 KB |
Output is correct |
90 |
Correct |
25 ms |
4948 KB |
Output is correct |
91 |
Correct |
24 ms |
4948 KB |
Output is correct |
92 |
Correct |
157 ms |
5844 KB |
Output is correct |
93 |
Correct |
147 ms |
5840 KB |
Output is correct |
94 |
Correct |
469 ms |
6840 KB |
Output is correct |
95 |
Correct |
553 ms |
6832 KB |
Output is correct |
96 |
Correct |
866 ms |
7428 KB |
Output is correct |
97 |
Correct |
822 ms |
7380 KB |
Output is correct |
98 |
Correct |
386 ms |
6536 KB |
Output is correct |
99 |
Correct |
389 ms |
6648 KB |
Output is correct |
100 |
Correct |
380 ms |
6632 KB |
Output is correct |
101 |
Correct |
393 ms |
6636 KB |
Output is correct |
102 |
Correct |
393 ms |
6636 KB |
Output is correct |
103 |
Correct |
405 ms |
6636 KB |
Output is correct |
104 |
Correct |
391 ms |
6632 KB |
Output is correct |
105 |
Correct |
394 ms |
6640 KB |
Output is correct |