Python Code chef |台式机问题-我解决了这个问题,并用示例测试用例部分解决了它。你能指出我遗漏了什么吗
Python3代码:Python Code chef |台式机问题-我解决了这个问题,并用示例测试用例部分解决了它。你能指出我遗漏了什么吗,python,testing,Python,Testing,Python3代码: testCases = int(input()) for i in range(testCases): line1 = [int(x) for x in input().split()] weights = [int(y) for y in input().split()] numberOfWeights,requiredWeight,rodWeight = line1[0],line1[1],line1[2] if (requiredWei
testCases = int(input())
for i in range(testCases):
line1 = [int(x) for x in input().split()]
weights = [int(y) for y in input().split()]
numberOfWeights,requiredWeight,rodWeight = line1[0],line1[1],line1[2]
if (requiredWeight <= rodWeight):
print("YES")
continue
lookupWeights = list()
for j in range(numberOfWeights):
if (requiredWeight <= rodWeight):
break
if(weights[j] in lookupWeights):
rodWeight += (2*weights[j])
lookupWeights.remove(weights[j])
else:
lookupWeights.append(weights[j])
if (requiredWeight <= rodWeight):
print("YES")
else:
print("NO")
你知道你失败是因为时间还是因为答案错误吗?我的意思是,对于一些测试用例来说,这会在时间上失败。这一个在时间和答案上都失败了。所以有两个隐藏的用例,时间限制是0.5秒,它在0.17秒失败
3
2 5 10
2 2
7 100 50
100 10 10 10 10 10 90
6 100 40
10 10 10 10 10 10
Output:
YES
NO
YES
TEST CASE 2:
1
8 100 40
10 20 10 25 30 40 30 50
Output:
YES