此代码AC×58 WA×9,求调PLS,ty。
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
bool dp[10005][54] = {1};
int a[54], b[54];
int main() {
int n, x;
cin >> n >> x;
for (int i = 1; i <= n; i ++) {
cin >> a[i] >> b[i];
}
for (int i = 1; i <= n; i ++) {
for (int j = 0; j <= b[i]; j ++) {
for (int k = 0; k <= x; k ++) {
if (k >= a[i] * j && dp[i - 1][k - a[i] * j]) {
dp[i][k] = 1;
}
}
}
}
cout << (dp[n][x] ? "Yes" : "No");
return 0;
}
wa wa