Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[100],b[100];
- int curent[10001],ina[10001];
- int main()
- {
- int i,n,x,j;
- cin>>n>>x;
- for(i=0;i<n;i++){
- cin>>a[i]>>b[i];
- }
- ina[0]=1;
- for(i=0;i<n;i++){
- for(j=0;j<=x;j++){
- if(ina[j]==1){
- if(a[i]+j<=x){
- curent[a[i]+j]=1;
- }
- if(b[i]+j<=x){
- curent[b[i]+j]=1;
- }
- }
- }
- for(j=0;j<=x;j++){
- ina[j]=curent[j];
- curent[j]=0;
- }
- }
- if(ina[x]==1)
- cout<<"Yes";
- else
- cout<<"No";
- return 0;
- }
Advertisement
Advertisement