HUAWEI 机试题:充分发挥GPU算力 (Python解法)

https://blog.csdn.net/weixin_47243236/article/details/122775971#comments_21461297

Python解法

N = int(input())
M = int(input())
arr = sorted(list(map(int, input().split(' '))))
res = 0
tmp = 0

for each in arr:
    res += 1
    if each + tmp > N:
        tmp -=  N - each
    else:
        tmp = 0
res += (tmp + 1) // N

print(res)

你可能感兴趣的:(算法,python)