Algorithm/lanqiao/series13sheng/ti_wa.py

24 lines
377 B
Python

import io
import sys
sys.stdin = io.StringIO('''5 1
1 4 2 8 5
''') # 4
n, k = map(int, input().split())
nums = list(map(int, input().split()))
def cal_dp(arr):
dp = [1] * n
for i in range(1, n):
for j in range(i):
if arr[i] > arr[j] and dp[i] < dp[j] + 1:
dp[i] = dp[j] + 1
return dp
dp = cal_dp(nums)
print(max(dp) + k)