Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bitset>
- using namespace std;
- bitset <10001> dp[2];
- int v[2500];
- int main()
- {
- int n,x,i,j,aux,a,b;
- cin>>aux>>x;
- for(i=0;i<aux;i++){
- cin>>a>>b;
- for(j=0;j<b;j++){
- v[n]=a;
- n++;
- }
- }
- dp[0][0]=1;
- for(i=0;i<n;i++){
- for(j=0;j<=x;j++){
- if(dp[0][j]==1){
- dp[1][j]=1;
- if(j+v[i]<=x)
- dp[1][j+v[i]]=1;
- }
- }
- for(j=0;j<=x;j++){
- dp[0][j]=dp[1][j];
- dp[1][j]=0;
- }
- }
- if(dp[0][x]==1)
- cout<<"Yes";
- else
- cout<<"No";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement