//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 115
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int n,k;
pii arr[N];
long double dp[N][N][N],ans=1e100;
bool vis[N];
vector<pii>tog,all;
long double solve(int use){
for (int i=0;i<=n;i++){
for (int j=0;j<=n;j++) dp[0][i][j]=1e18;
}
dp[0][0][0]=0;
for (int i=1;i<=n;i++){
for (int j=0;j<=n;j++){
for (int h=0;h<=use;h++){
dp[i][j][h]=dp[i-1][j][h];
if (j&&j<=i) dp[i][j][h]=min(dp[i-1][j-1][h]+(long double)(arr[i].x)/(use+1),dp[i][j][h]);
if (arr[i].y!=-1&&h&&h<=i&&j<=i&&j){
dp[i][j][h]=min(dp[i][j][h],dp[i-1][j-1][h-1]+(long double)(arr[i].y)/(h));
}
// cout<<dp[i][j][h]<<' ';
}
// cout<<'\n';
}
// cout<<'\n';
}
// cout<<'\n';
return dp[n][k][use];
}
bool cmp(pii a,pii b){
if (a.y!=b.y) return a.y<b.y;
return a.x<b.x;
}
signed main(){
fast
cout<<fixed<<setprecision(20);
cin>>n>>k;
for (int i=1;i<=n;i++) cin>>arr[i].x>>arr[i].y;
sort(arr+1,arr+1+n,cmp);
for (int i=0;i<=k;i++){
ans=min(ans,solve(i));
}
cout<<ans<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Runtime error |
3 ms |
452 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Runtime error |
3 ms |
452 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
1 ms |
1100 KB |
Output is correct |
17 |
Correct |
1 ms |
1172 KB |
Output is correct |
18 |
Correct |
1 ms |
1096 KB |
Output is correct |
19 |
Correct |
1 ms |
1100 KB |
Output is correct |
20 |
Correct |
1 ms |
1100 KB |
Output is correct |
21 |
Correct |
1 ms |
1100 KB |
Output is correct |
22 |
Correct |
1 ms |
1100 KB |
Output is correct |
23 |
Correct |
1 ms |
1100 KB |
Output is correct |
24 |
Correct |
2 ms |
1100 KB |
Output is correct |
25 |
Correct |
2 ms |
1100 KB |
Output is correct |
26 |
Correct |
2 ms |
1100 KB |
Output is correct |
27 |
Correct |
1 ms |
1096 KB |
Output is correct |
28 |
Correct |
1 ms |
1092 KB |
Output is correct |
29 |
Correct |
1 ms |
1096 KB |
Output is correct |
30 |
Correct |
1 ms |
1100 KB |
Output is correct |
31 |
Correct |
1 ms |
1100 KB |
Output is correct |
32 |
Correct |
1 ms |
1100 KB |
Output is correct |
33 |
Correct |
1 ms |
1100 KB |
Output is correct |
34 |
Correct |
2 ms |
1100 KB |
Output is correct |
35 |
Correct |
1 ms |
1100 KB |
Output is correct |
36 |
Correct |
1 ms |
1092 KB |
Output is correct |
37 |
Correct |
1 ms |
1100 KB |
Output is correct |
38 |
Correct |
1 ms |
1100 KB |
Output is correct |
39 |
Correct |
1 ms |
1096 KB |
Output is correct |
40 |
Correct |
1 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
1 ms |
1100 KB |
Output is correct |
17 |
Correct |
1 ms |
1172 KB |
Output is correct |
18 |
Correct |
1 ms |
1096 KB |
Output is correct |
19 |
Correct |
1 ms |
1100 KB |
Output is correct |
20 |
Correct |
1 ms |
1100 KB |
Output is correct |
21 |
Correct |
1 ms |
1100 KB |
Output is correct |
22 |
Correct |
1 ms |
1100 KB |
Output is correct |
23 |
Correct |
1 ms |
1100 KB |
Output is correct |
24 |
Correct |
2 ms |
1100 KB |
Output is correct |
25 |
Correct |
2 ms |
1100 KB |
Output is correct |
26 |
Correct |
2 ms |
1100 KB |
Output is correct |
27 |
Correct |
1 ms |
1096 KB |
Output is correct |
28 |
Correct |
1 ms |
1092 KB |
Output is correct |
29 |
Correct |
1 ms |
1096 KB |
Output is correct |
30 |
Correct |
1 ms |
1100 KB |
Output is correct |
31 |
Correct |
1 ms |
1100 KB |
Output is correct |
32 |
Correct |
1 ms |
1100 KB |
Output is correct |
33 |
Correct |
1 ms |
1100 KB |
Output is correct |
34 |
Correct |
2 ms |
1100 KB |
Output is correct |
35 |
Correct |
1 ms |
1100 KB |
Output is correct |
36 |
Correct |
1 ms |
1092 KB |
Output is correct |
37 |
Correct |
1 ms |
1100 KB |
Output is correct |
38 |
Correct |
1 ms |
1100 KB |
Output is correct |
39 |
Correct |
1 ms |
1096 KB |
Output is correct |
40 |
Correct |
1 ms |
1100 KB |
Output is correct |
41 |
Correct |
26 ms |
18920 KB |
Output is correct |
42 |
Correct |
21 ms |
18892 KB |
Output is correct |
43 |
Correct |
64 ms |
18920 KB |
Output is correct |
44 |
Correct |
62 ms |
18928 KB |
Output is correct |
45 |
Correct |
156 ms |
18888 KB |
Output is correct |
46 |
Correct |
157 ms |
18972 KB |
Output is correct |
47 |
Correct |
246 ms |
19060 KB |
Output is correct |
48 |
Correct |
239 ms |
19004 KB |
Output is correct |
49 |
Correct |
354 ms |
19128 KB |
Output is correct |
50 |
Correct |
336 ms |
19016 KB |
Output is correct |
51 |
Correct |
479 ms |
19068 KB |
Output is correct |
52 |
Correct |
499 ms |
19044 KB |
Output is correct |
53 |
Correct |
242 ms |
18892 KB |
Output is correct |
54 |
Correct |
247 ms |
18936 KB |
Output is correct |
55 |
Correct |
245 ms |
18892 KB |
Output is correct |
56 |
Correct |
248 ms |
19108 KB |
Output is correct |
57 |
Correct |
241 ms |
18936 KB |
Output is correct |
58 |
Correct |
245 ms |
18968 KB |
Output is correct |
59 |
Correct |
259 ms |
19204 KB |
Output is correct |
60 |
Correct |
239 ms |
18984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Runtime error |
3 ms |
452 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |