image

太难了谁会做?大佬求解......

5 条评论

  • @ 2024-3-24 10:18:33

    image image 我建议用结构体

    👍 2
    • @ 2024-3-18 23:56:47

      image image image

      冯翔是joker

      🌿 2
      👎 1
      😄 1
      🕊️ 1
      • @ 2024-3-18 20:25:40

        image image

        ***~~~~~~~~***菜

        👍 3
        • @ 2024-3-18 20:23:07

          image 现在我做出来了👎 菜就多练

          👍 3
          • @ 2024-3-18 20:21:03
            //杜锦凝菜就多练,简单题目都不会👎 
            #include<bits/stdc++.h>
            using namespace std;
            int n, m, aw[100], av[100], bw[100][2], bv[100][2], dp[105][100005];
            int main(){
                cin >> n >> m;
                for(int i = 1; i <= m; i++){
                    int v, p, q;
                    cin >> v >> p >> q;
                    if(q == 0){
                        aw[i] = v, av[i] = v * p;
                    }
                    else{
                        if(!bw[q][0] && !bv[q][0]) bw[q][0] = v, bv[q][0] = v * p;
                        else bw[q][1] = v, bv[q][1] = v * p;
                    }
                }
                for(int i = 1; i <= m; i++){
                    for(int j = 0; j <= n; j += 10){
                        dp[i][j] = dp[i - 1][j];
                        if(j >= aw[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - aw[i]] + av[i]);
                        if(j >= aw[i] + bw[i][0]) dp[i][j] = max(dp[i][j], dp[i - 1][j - aw[i] - bw[i][0]] + av[i] + bv[i][0]);
                        if(j >= aw[i] + bw[i][1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - aw[i] - bw[i][1]] + av[i] + bv[i][1]);
                        if(j >= aw[i] + bw[i][0] + bw[i][1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - aw[i] - bw[i][0] - bw[i][1]] + av[i] + bv[i][0] + bv[i][1]);
                    }
                }
                cout << dp[m][n];
                return 0;
            }
            
            👍 3
            👎 1
          • 1