RE求助
查看原帖
RE求助
1014715
HuangTingFu楼主2024/5/2 21:31
#include<bits/stdc++.h>
using namespace std;
const int N=1000000000;
int cost[2001];
int main()
{
    int n,l;
    cin>>n>>l;
    cost[0]=0;
    for(int i=1;i<=l;i++)
    {
      cost[i]=N;
    }
    for(int i=0;i<=n;i++)
    {
        int c,l;
        cin>>c>>l;
        for(int j=l;j>=0;j++)
        {
          cost[j]=min(cost[j],cost[max(j-1,0)]+c);
        }
    }
    if(cost[l]=N) cout<<"no solution";
    else cout<<cost[l];
    return 0;
}
2024/5/2 21:31
加载中...