商汤-智慧商业-算法笔试1.2题

居然能ac,有点怀疑。。
第一题:
n,c = map(int,input().rstrip().split())
nlist = list(map(int,input().rstrip().split()))
nlist.sort(reverse=True)
res = 0
i=0
while i < n:
    res += nlist[i]
    i += c
print(res)
第二题:
n = int(input().rstrip())
Xi = list(map(int,input().rstrip().split()))
Xi.sort()
count = 0
for i in range(n):
    count += abs(Xi[i]-i-1)
print(count)




#笔试题目##商汤科技##算法工程师#
全部评论
题目是啥
点赞 回复 分享
发布于 2019-08-19 21:50

相关推荐

11-14 16:15
已编辑
湖南工业大学 Java
点赞 评论 收藏
分享
程序员花海:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
点赞 评论 收藏
分享
评论
2
2
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务