Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
142103 苏唯哲 采药 C++ 运行出错 0 0 MS 80 KB 322 2024-04-06 16:35:53

Tests(0/12):


#include<bits/stdc++.h> using namespace std; int w[10001],c[10001],f[10001][10001],m,n; int main(){ cin>>m>>n; for(int i=1;i<=n;i++)cin>>w[i]>>c[i]; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(j>=w[i])f[i][j]=max(f[i-1][j-w[i]]+c[i],f[i-1][j]); else f[i][j]=f[i-1][j]; } } cout<<f[n][m]; }


测评信息: