#include<bits/stdc++.h> usingnamespace std; longlong bit[15][100005]; int n; intlowbit(int x) { return x & -x; } voidadd(int i, int num, longlong x) { while (num <= n) { bit[i][num] += x; num += lowbit(num); } } longlongdp(int i, int x)//求长度为i,末尾元素值不超过x的上升子序列个数 { longlong ret = 0; while (x > 0) { ret += bit[i][x]; x -= lowbit(x); } return ret; } intmain() { int k, i, j, a; scanf("%d%d", &n, &k); longlong res = 0; for (i = 1; i <= n; i++) { scanf("%d", &a); res += dp(k, a); for (j = k; j > 1; j--) add(j, a, dp(j - 1, a)); add(1, a, 1); } if (k == 0) //边界未处理,需特判 res = n; printf("%lld", res); return0; }