2590353417l @ 2021-12-14 20:41:16
#include<stdio.h>
#include<malloc.h>
#include<math.h>
int main()
{
int m,n,sum=0,*a;
scanf("%d %d",&m,&n);
a=(int *)malloc(m*sizeof(int));
for(int i=0;i<m;i++)
scanf("%d",&a[i]);
for(int j=0;j<n;j++)
{
int s,min;
scanf("%d",&s);
min=fabs(s-a[0]);
for(int i=1;i<m;i++)
{
if(fabs(s-a[i])<min)
min=fabs(s-a[i]);
}
sum+=min;
}
printf("%d\n",sum);
return 0;
}
才三十分我服了,感觉没问题,
by IaLWH @ 2021-12-14 20:43:36
你倒是free啊你
by 2590353417l @ 2021-12-14 20:44:59
@PluckDuck 怎么搞?
by IaLWH @ 2021-12-14 21:15:34
@2590353417l bdfs free(a);
估计加了也没用