商汤-智慧商业-算法笔试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

相关推荐

牛客837006795号:简历抄别人的,然后再投,有反馈就是简历不行,没反馈就是学历不行,多投多改只要技术不差机会总会有的
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-24 20:25
腾讯今年实习招了这么多人,后面秋招还会招人吗??想着秋招再战来着
牛客965593684号:腾讯好像2020年之后就是实习生招得多,应届生基本上不招,纯实习转正
点赞 评论 收藏
分享
评论
2
2
分享

创作者周榜

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