听取TLE声一片
def missile_interception(heights):
n = len(heights)
max_interceptions = [1] * n
for i in range(n):
for j in range(i):
if heights[i] <= heights[j] and max_interceptions[j] + 1 > max_interceptions[i]:
max_interceptions[i] = max_interceptions[j] + 1
max_interception_count = max(max_interceptions)
return max_interception_count
def systems_needed(heights):
dp = [heights[0]]
for i in range(len(heights)):
tmp_index = []
tmp_num = []
flag = True
for j in range(len(dp)):
if heights[i] <= dp[j]:
flag = False
tmp_index.append(j)
tmp_num.append(dp[j])
if flag:
dp.append(heights[i])
else:
dp[tmp_index[tmp_num.index(min(tmp_num))]] = heights[i]
return len(dp)
heights = list(map(int, input().split()))
print(missile_interception(heights))
print(systems_needed(heights))