题意:n在1e5 m在50以内 存在多少个m元组满足条件
思路:从三元组的扩展 对于数组中的某一个点 对答案的贡献就是 左边小于他的数 x 右边大于他的数
所以考虑构造m个树状数组来维护和查询
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mes(x,a) memset(x,a,sizeof(x));
#define sca(a) scanf("%d",&a)
#define lowbit(x) x & (-x)
#define fi first
#define se second
#define pii pair<int, int>
inline int read()
{
int x=0,flag_read=1;
char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-')
flag_read=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
x=(x<<3)+(x<<1)+c-'0';
c=getchar();
}
return x*flag_read;
}
const double eps=1e-9;
const double pi=acos(-1);
const int N = 100050;
const int M = 1e7+5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
LL c[N][51],a[N],b[N];
void update(LL x,LL k,LL v)
{
for(;x < N ;x += lowbit(x))
c[x][k] = (c[x][k] + v)%mod;
}
LL query(LL x,LL k)
{
LL res = 0;
for(;x > 0 ;x -= lowbit(x))
res = (res + c[x][k])%mod;
return res;
}
int main()
{
int n,m;
n = read();
m = read();
for(int i = 1;i <= n;i ++)
a[i] = b[i] = read();
sort(b + 1,b + 1 + n);
int len = unique(b + 1,b + 1 + n) - b - 1;
for(int i = 1;i <= n;i ++)
a[i] = lower_bound(b + 1,b + 1 + len,a[i]) - b;
for(int i = 1;i <= n;i ++)
{
update(a[i],1,1);
for(int j = 2;j <= m;j ++)
update(a[i],j,query(a[i] - 1,j - 1));
}
printf("%lld\n",query(n,m));
return 0;
}