https://ac.nowcoder.com/acm/contest/696/D
反思:要剔除重复的,T是集合!!dp[i]表示集合有多少元素,枚举元素增加它对集合的贡献,要注意dp更新顺序~
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<cstring>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<cstdio>
#include<map>
#include<stack>
#include<string>
#include<bits/stdc++.h>
using namespace std;
#define sfi(i) scanf("%d",&i)
#define pri(i) printf("%d\n",i)
#define sff(i) scanf("%lf",&i)
#define ll long long
#define ull unsigned long long
#define mem(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define eps 1e-16
#define PI acos(-1)
#define lowbit(x) ((x)&(-x))
#define zero(x) (((x)>0?(x):-(x))<eps)
#define fl() printf("flag\n")
#define MOD(x) ((x%mod)+mod)%mod
#define endl '\n'
#define pb push_back
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int maxn=1e6+9;
const int mod=1e9+7;
inline ll read()
{
ll f=1,x=0;
char ss=getchar();
while(ss<'0'||ss>'9')
{
if(ss=='-')f=-1;ss=getchar();
}
while(ss>='0'&&ss<='9')
{
x=x*10+ss-'0';ss=getchar();
} return f*x;
}
ll a[maxn],dp[maxn];
int main()
{
//FAST_IO;
//freopen("input.txt","r",stdin);
int n,k;
cin>>n>>k;
set<ll>s;
for(int i=1;i<=n;i++)
cin>>a[i],s.insert(a[i]);
int cnt=0;
for(set<ll>::iterator it=s.begin();it!=s.end();it++) a[++cnt]=*it;
dp[0]=1;
for(int i=1;i<=cnt;i++)
{
for(int j=k;j>=0;j--)
{
dp[j]+=(dp[j-1]*a[i]%mod);
dp[j]%=mod;
}
}
ll ans=0;
for(int i=0;i<=k;i++)
{
//cout<<dp[i]<<" ";
ans+=dp[i];
ans%=mod;
}
cout<<ans<<endl;
return 0;
}