3.11-3.13 PAT1030 乙级 python(我猜可能超时了 等后期修改)

完美数列

n,p = map(int,input().split())
lst = list(map(int,input().split()))
lst.sort()
mostl = 0
for i in range(n-1):
	l = 0
	for j in range(i+1,n):
		if lst[j]/lst[i]<=p:
			l += 1
		if l > mostl:
			mostl = l
	if mostl>= n-i:
		break
print(mostl+1)

额额额额。。服务器错误了。。看不到自己错在哪。。但是我感觉自己思路应该没错,大概率是超时了。等服务器正常了再来改。。

猜你喜欢

转载自blog.csdn.net/qq_39782006/article/details/88539906
今日推荐