代码传输 请在传输代码时每行加换行 以便他人使用

3 条评论

  • @ 2025-7-4 13:36:06

    #include <bits/stdc++.h> using namespace std; int main() { int T, N, M; cin >> T >> N >> M; vector<vector> prices(T + 1, vector(N + 1)); for (int i = 1; i <= T; i++) { for (int j = 1; j <= N; j++) { cin >> prices[i][j]; } } vector money(T + 1); money[1] = M; for (int day = 1; day < T; day++) { int currentMoney = money[day]; vector dp(currentMoney + 1, 0);

        for (int j = 1; j <= N; j++) {
            int buyPrice = prices[day][j];
            int sellPrice = prices[day + 1][j];
            if (sellPrice <= buyPrice) continue;
    
            int profit = sellPrice - buyPrice;
            for (int k = buyPrice; k <= currentMoney; k++) {
                dp[k] = max(dp[k], dp[k - buyPrice] + profit);
            }
        }
        int maxProfit = 0;
        for (int k = 0; k <= currentMoney; k++) {
            maxProfit = max(maxProfit, dp[k]);
        }
        money[day + 1] = currentMoney + maxProfit;
    }
    cout << money[T] << endl;
    return 0;
    

    }

    • @ 2025-7-2 10:35:57

      不给不给就不给

      • @ 2025-7-1 10:30:30

        #include <bits/stdc++.h>

        using namespace std;

        queuef;

        int main(){

        for(int i=1;i<=5;i++){
        
        	q.push(i);
        
        }
        
        cout<<q.size()<<endl;
        
        cout<<q.front()<<endl;
        
        cout<<q.back()<<endl;
        
        q.pop();
        
        q.pop();
        
        cout<<q.front()<<endl;
        
        cout<<q.size()<<endl;
        
        while(!q.front()){
        
        	cout<<q.front()<<endl;
        
        	q.pop();	
        
        }
        

        return 0;

        }

        • 1

        信息

        ID
        3
        时间
        1000ms
        内存
        256MiB
        难度
        7
        标签
        (无)
        递交数
        2207
        已通过
        554
        上传者