9-21吉比特AK 游戏研发工程师
全部评论
请问游戏研发岗笔试就是算法题吗
import sys
n = int(input())
array = list(map(int,input().split()))
dp = [0]*n
dp[0] = array[0]
for i in range(1,n):
for j in range(i,-1,-1):
if j == 0 or sum(array[j:i+1]) >= dp[j-1]:
dp[i] = sum(array[j:i+1])
break
i,count = n-1,1
res = dp[-1]
while i >= 0:
if res != 0:
res -= array[i]
i -= 1
else:
count += 1
res = dp[i]
print(count)
按大佬说的写了下代码,不确定对不对,当时候看到题直接懵了
好兄弟能贴一下第二题代码吗,太难了
大佬能不能细说一下第二题
相关推荐

点赞 评论 收藏
分享