|
|
вернуться в форумhelp me find a test data for the error. #include <stdio.h> #include <stdlib.h> main() { int i,j,k,t; int sum; int max; int mark; int a[22]; int* x; x=(int*)malloc(1048578*sizeof(int)); scanf("%d",&a[0]); for(i=1,sum=0;scanf("%d",&t)!=EOF;i++) { for(j=1;j<=i-1 && t>a[j];j++); for(k=i-1;k>=j;k--){a[k+1]=a[k];} a[j]=t; sum+=t; } x[0]=1;x[1]=0; for(i=1;i<=a[0];i++) { for(j=1,mark=0,max=0;j<=x[0];j++) { x[j+x[0]]=x[j]+a[i]; if(x[j]+a[i]<=sum/2) max=max>x[j]+a[i]?max:x[j]+a[i]; } x[0]*=2; } printf("%d",sum-2*max); } I test it with a large data but can't find error... |
|
|