I think that it will fail if the value of the coins can be more than 50001. Don
On Sep 29, 12:35 pm, manish patel <manispatel...@gmail.com> wrote: > http://www.spoj.pl/problems/PIGBANK/ > > please suggest some test case where it fails ... > > [code] > #include<stdio.h> > main() > { int t=0,n,e,f,i,j; > int p[50002],w[10002]; > scanf("%d",&t); > while(t--) > { scanf("%d %d",&e,&f); > scanf("%d",&n); > for(i=0;i<n;i++) > { scanf("%d %d",&p[i],&w[i]); > } > int min[f-e+2]; > for(i=e;i<=f+2;i++) > { min[i-e]=50001; > } > min[0]=0; > for(i=e+1;i<=f;i++) > { for(j=0;j<n;j++) > { if(w[j]<=(i-e)&& min[i-e-w[j]]+p[j] < min[i-e]) > min[i-e]=min[i-e-w[j]]+p[j]; > > } > } > if(min[f-e]==50001||min[f-e]==0) > printf("This is impossible.\n"); > else > printf("The minimum amount of money in the piggy-bank is > %d.\n",min[f-e]); > } > return 0; > > } > > [/code] > > -- > With Regards > > Manish Patel > BTech > Computer Science And Engineering > National Institute of Technology -Allahabad -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.