WA求助
查看原帖
WA求助
937492
mori_0226楼主2023/12/24 09:57

我脑子what了……

题目传送门

#include<bits/stdc++.h>
using namespace std;
const int INF = 100000000;
int cost[2001];
int main(){
    int N = 0,L = 0;
    cin >> N >> L;
    cost[0] = 0;
    for(int i = 1;i < L;i++){
        cost[i] = INF;
    }
    for(int i = 0;i < N;i++){
        int c = 0,l = 0;
        cin >> c >> l;
        for(int j = L;j >= 0;j--){
            cost[j] = min(cost[j],cost[max(j - 1,0)] + c);
        }
    }
    if(cost[L] == INF){
        cout << "no solution" << endl;
    }else{
        cout << cost[L] << endl;
    }
    return 0;
}
2023/12/24 09:57
加载中...