为什么我的代码显示“超过时限”错误?有没有相关的问题?我是否使用任何可能导致错误的内建函数?
while True:
str_input = input()
n = int(str_input.split()[0])
m = int(str_input.split()[1])
if n == 0 and m == 0:
break
if n > m:
print("Loowater is doomed!")
break
head_diameter_list = []
knights_height_list = []
for i in range(n):
head_diameter_list.append(int(input()))
for i in range(m):
knights_height_list.append(int(input()))
head_diameter_list.sort()
knights_height_list.sort()
selected_knights_list = [0]
for i in range(n):
for j in range(m):
if knights_height_list[j] >= head_diameter_list[i]:
selected_knights_list.append(knights_height_list[j])
break
p = len(head_diameter_list)
q = len(selected_knights_list)-1
if p <= q:
print(sum(selected_knights_list))
else:
print("Loowater is doomed!")