YiBoRrui6 @ 2022-08-11 22:44:09
在这道题上已被困2个月 求各位神犇帮蒟蒻看一下有什么错误!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include<bits/stdc++.h>
using namespace std;
int m, n;
int bmy=0;
int gf[100050], lqx[100050];
int main()
{
scanf("%d%d", &m, &n);
for (int i = 0; i <= m-1; i++)
scanf("%d", &lqx[i]);
for (int i = 0; i <= n-1; i++)
scanf("%d", &gf[i]);
sort(lqx, lqx+n);
for (int i = 0; i <= m-1; i++)
{
int l=0, r=n, mid;
while (l < r)
{
mid = (l+r)/2;
lqx[mid] <= gf[i] ? l = mid+1 : r = mid;
}
gf[i] <= lqx[0] ? bmy += lqx[0] - gf[i] : bmy += min(abs(lqx[l-1]-gf[i]), abs(lqx[l]-gf[i]));
}
printf("%d", bmy);
return 0;
}
by Acam @ 2022-08-11 22:52:34
建议直接交原tj测试
注:要加上//test
by YiBoRrui6 @ 2022-08-12 08:30:58
@AC_Automata 原题解???蒟蒻真的不知道是哪 能给我一个传送门吗qwq
by Acam @ 2022-08-12 12:11:39
@MichealCoding6 我其实可不知道,但是都两个月了的话这个tj可能已经撤掉了
by Ted_Algorithm @ 2022-08-19 00:21:34
@YiBoRrui6 sort(lqx, lqx+m); 不是+n 你要排序的是学校的录取线,不是估分 然后for循环是对所有学生的估分进行遍历 for (int i = 0; i <= n-1; i++)
by YiBoRrui6 @ 2022-08-19 11:11:19
@maodi198911 还是不正确qwq但是AC了一个点