求助!!!
查看原帖
求助!!!
1023732
FlowerAccepted楼主2024/10/25 19:25

此代码AC×\times58 WA×\times9,求调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 wawa\ wa

2024/10/25 19:25
加载中...