对不合法的数字不作处理。continue
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
#define MAXN (200000+10)
int a[MAXN], dp[MAXN];
#define INF (1e9)
int main()
{
int n, k;
cin >> n >> k;
for(int i = 1; i <= n; i ++)
scanf("%d", &a[i]), dp[i] = INF;
for(int i = 1; i <= n; i ++)
{
if(i < k && a[i] > a[k])
continue;
if(i > k && a[i] < a[k])
continue;
dp[lower_bound(dp+1, dp+n+1, a[i])-dp] = a[i];
}
cout << (lower_bound(dp+1, dp+n+1, INF)-dp-1) << endl;
return 0;
}