import sys n, k = list(map(int, sys.stdin.readline().strip().split())) l = list(map(int, sys.stdin.readline().strip().split())) def judge(l, k): for i in set(l): if l.count(i) == k: return True return False found = False res = 0 while not found: if judge(l, k): print(res) found = True l[l.index(max(l))] -= 1 res += 1 if judge(l, k): print(res) found = True l[l.index(min(l))] += 1 res += 1 但是没通过,不知道咋回事
点赞 评论

相关推荐

12-10 22:48
武汉大学 Java
点赞 评论 收藏
分享
11-06 23:30
已编辑
华中师范大学 后端工程师
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务