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";
}
}