ACcode:
-
- #include<bits/stdc++.h>
- using namespace std;
- #define int long long
- const int N=55;
- int n,x,a[N],b[N],f[10100];
- void solve() {
-
- 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=x; j>=a[i]; j--) {//“背包体积”
- for(int k=0; k<=b[i]&&k*a[i]<=j; k++) {//当前物品的数量
- f[j]=max(f[j],f[j-k*a[i]]+k*a[i]);
- }
- }
- }
- if(f[x]==x)cout<<"Yes\n";
- else cout<<"No\n";
- }
- signed main() {
- ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
- int t=1;
- //cin>>t;
- while(t--) {
- solve();
- }
- return 0;
- }
-
-
-
over