无产者万岁 @ 2019-07-15 10:57:36
#include <bits/stdc++.h>
using namespace std;
int minn=1000001;
int main()
{
int s=0;
int b[100001],a[100001],n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>b[i];
for(int i=1;i<=m;i++)
{
cin>>a[i];
for(int j=1;j<=n;j++)
minn=min(abs(b[j]-a[i]),minn);
s+=minn;
minn=1000001;
}
cout<<s;
return 0;
}
by 紪絽 @ 2019-07-15 11:02:27
前排
哪一题啊
by Omphalos @ 2019-07-15 11:05:11
O(n*m)能过吗。。。
by Omphalos @ 2019-07-15 11:06:21
@zyz20080227 至少也要二分吧。。。
by 药尘 @ 2019-07-15 11:13:30
cin改成scanf,cout改成printf你试一试吧
by lionrenard @ 2019-08-26 18:53:30
不用就是40分
by 孤独的死男孩 @ 2019-10-15 17:20:46
+1前排
by 孤独的死男孩 @ 2019-10-15 17:20:56
自己看数据