这段代码是为GoogleCodeJam竞赛编写的。下面的代码在我的电脑上正确编译,并给出了示例代码的正确结果。然而,每当我试图在谷歌网站上运行它时,它就会显示运行时错误。我把它弄乱了一个小时,仍然不知道它出了什么问题
def reversort(reverList):
global totalScore
length = len(reverList)
score = 0
for i in range(length - 1):
minimum = reverList.index(min(reverList[i: ]))
tempList = reverList[i:minimum + 1]
tempList.reverse()
reverList[i: minimum + 1] = tempList
score += minimum - i + 1
totalScore.append(score)
if __name__ == "__main__":
t = int(input())
totalScore = []
rev = []
for i in range(t):
n = int(input())
apen = []
for j in range(n):
apen.append(int(input()))
reversort(apen)
print("Case #{}: {}".format(i+1,totalScore[i]))
rev.append(apen)
试试这个
相关问题 更多 >
编程相关推荐