XG0701
XG0701
全部文章
分类
题解(13)
归档
标签
去牛客网
登录
/
注册
XG0701的博客
全部文章
(共1篇)
题解 | 2024/10/15(中位数贪心)(Python)
注意点: (1)最优位置是选在左中位数或右中位数处 (2)如果不在这两点,左右移动时增加的距离会大于减小的距离 N = int(input()) a = list(map(int, input().split())) a.sort() print(sum(abs(x - a[N // 2]) for...
Python3
贪心
2024-10-15
0
50