文章
72
粉丝
142
获赞
5
访问
58.5k
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int w[maxn];
int dp[maxn][maxn] = {0};
int main() {
int s, n;
while (cin>>s>>n) {
memset(dp,0,sizeof(dp));
for (int i = 1; i <= n;i++) {
cin >> w[i];
}
dp[0][0] = 1;
for (int i = 1; i <= n;i++) {
for (int j=s; j >= 0;j--) {
if (dp[i - 1][j] == 1)
dp[i][j] = 1;
if (j>=w[i]&& ...
登录后发布评论
暂无评论,来抢沙发