题目描述
题目链接
C++代码
#include<bits/stdc++.h>
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i ++)
#define REP(i, a, b) for(int i = a; i <= b; i ++)
#define fi first
#define se second
#define mp make_pair
#define SZ(x) ((int)(x).size())
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const int N = 110;
const int M = 11000;
bool dp[N][M];
int a[N], b[N];
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL Pow(LL a, LL k){LL res = 1; while(k){if(k & 1) res *= a; k >>= 1; a *= a;} return res;}
mt19937 rnd(random_device{}());
int mrand(int x){return rnd() % x;}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
dp[0][0] = 1;
int n, x;
cin >> n >> x;
REP(i, 1, n) cin >> a[i] >> b[i];
REP(i, 0, n)
REP(j, 0, x){
if(dp[i][j]){
if(a[i + 1] + j <= x) dp[i + 1][a[i + 1] + j] = true;
if(b[i + 1] + j <= x) dp[i + 1][b[i + 1] + j] = true;
}
}
if(dp[n][x]) cout << "Yes" << '\n';
else cout << "No" << '\n';
return 0;
}