Wi110w @ 2020-09-22 19:20:52
#include<bits/stdc++.h>
using namespace std;
int sc[100005],m,n;
int stu,maxx,ans;
int main(){
scanf("%d%d",&m,&n);
for(int i=1;i<=m;i++)
scanf("%d",&sc[i]);
sort(sc+1,sc+m+1);
for(int i=1;i<=n;i++){
scanf("%d",&stu);
ans+=min(abs(sc[lower_bound(sc+1,sc+m,stu)-sc]-stu),abs(stu-sc[(lower_bound(sc+1,sc+m,stu)-sc)-1]));
}
printf("%d",ans);
return 0;
}
by Wi110w @ 2020-09-22 19:27:35
wa了3,8,10点
by Wu_Ren @ 2020-09-22 19:49:10
2 1
300 600
110
在这个数据中你 WA
了,自己想想吧