Piggy Bank WA

codechef problem link

This shows wrong answer in the judge
Please help me to figure out what I am doing wrong

    #include <iostream>
#include <vector>
using namespace std;

int main()
{
   int t;
   cin>>t;
   
   while(t--)
   {
       long long int  m,n,INF=(1L<<63 - 1);
       cin>>n>>m; 
       long long int size = m - n;
       cin>>n;
       vector<long long int> ans(size+1,INF);
       int weight[n],coin[n];
       
       for(int i=0;i<n;i++)
       {
           cin>>coin[i]>>weight[i];
           
           if(size>=weight[i])
           ans[weight[i]]=coin[i];
       }
       
       
       for(int i=1;i<=size;i++)
       {
          
           for(int j=i-1;j>=i/2;j--)
           {
               if(ans[j]!=INF&&ans[i-j]!=INF)
               {
                   ans[i] = min( ans[i] , ans[j] + ans[i-j] );
               }
               
           }
       }
       
       if(ans[size]==INF)
       cout<<"This is impossible.\n";
       
       else
       cout<<"The minimum amount of money in the piggy-bank is "<<ans[size]<<"\n";
       
         
   }
    
}

Hello bajihalo

First of all, Yours AC solution

Let me point some mistakes of yours …


#include 
#include 
using namespace std;

int main()
{
   int t;
   cin>>t;

   while(t--)
   {
       long long int  m,n,INF=(1LL <>n>>m; 
       long long int size = m - n;
       cin>>n;
       vector ans(size+1,INF);
       int weight[n],coin[n];

       for(int i=0;i>coin[i]>>weight[i];

           if(size>=weight[i])
           ans[weight[i]]=coin[i];
       }

       ans[0] = 0 ; 	
       for(int i=1;i<=size;i++)
       {
           for(int j=0;j=weight[j]){	
              	 	if(ans[i-weight[j]]!=INF)
               		{
                   		ans[i] = min(ans[i],ans[i-weight[j]] + coin[j]);
                  	}
		}
           }
       }

       if(ans[size]==INF)
      	 cout<<"This is impossible.\n";
       else
         cout<<"The minimum amount of money in the piggy-bank is "<<ans[size]<<".\n"; // //here you were period while printing the output .. 


   }
   return 0 ;	
}

Here is the link to the much more elegant implementation of above solution http://www.codechef.com/viewsolution/5946748

Here is the link to your Ac solution
http://www.codechef.com/viewsolution/5946722

thank you,but then also what cases are missing in my code ,because of it showing WC.