1 #include<bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4 const int N = 110;
5
6 double dp[N][N * N];
7 int a[N], b[N];
8
9 int main()
10 {
11 ios_base::sync_with_stdio(0);
12 cin.tie(0);cout.tie(0);
13 int n; cin >> n;
14 for(int i = 1 ; i <= n ; i++){
15 cin >> a[i] >> b[i];
16 }
17 memset(dp, ~0x3f, sizeof(dp));
18 dp[0][0] = 0;
19 for(int i = 1 ; i <= n ; i++){
20 for(int j = n ; j >= 0 ; j--){
21 for(int k = 10000 ; k >= 0 ; k--){
22 dp[j][k] = max(dp[j][k], dp[j][k] + b[i] * 1.0 / 2);//
23 if(j > 0 && k >= a[i]){
24 dp[j][k] = max(dp[j][k], dp[j - 1][k - a[i]] + b[i]);//背包,从后往前更新
25 }
26 }
27 }
28 }
29 for(int i = 1 ; i <= n ; i++){
30 double ans = 0;
31 for(int j = 0 ; j <= 10000 ; j++){
32 ans = max(ans, min(dp[i][j], 1.0 * j));//最后用容量更新
33 }
34 cout << fixed << setprecision(20) << ans << " ";
35 }
36 return 0;
37 }//韩教tql
说实话还是没怎么看懂