#pragma GCC optimize ("-O3","unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define m0(x) memset(x,0,sizeof(x)) #define print(x) cout< inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int MOD = (ll)1000000000 + 7; const ll INF = 1e17; const double pi = acos(-1); const double EPS = 1e-10; typedef pairP; const int MAX = 200020; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; } ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; } ll mult(ll x, ll y) { return (x * y) % MOD; } ll bin_pow(ll x, ll p) { if (p == 0) return 1; if (p & 1) return mult(x, bin_pow(x, p - 1)); return bin_pow(mult(x, x), p / 2); } ll dp[303][50000]; vectorv; int N, K; ll cum[303][500000]; signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> K; REP(i, N) { int a; cin >> a; v.pb(a); } VSORT(v); VREVERSE(v); dp[1][0] = 1; FOR(j,1, K + 2)cum[1][j] = 1; int cnt = 0; FOR(i, 1, N) { if (v[i] < v[i - 1])cnt++; REP(j, K + 1) { int res = 0; int counter = min(cnt + 1, j+1); if (counter == j + 1) { res = cum[i][j+1]; } else { res = sub(cum[i][j+1], cum[i][j - cnt]); } /*REP(k, counter) { res =add(res, dp[i][j - k]); }*/ dp[i + 1][j] = res; //pe(i + 1)pe(j)print(res); } cum[i + 1][1] = dp[i + 1][0]; FOR(j, 1, K + 1) { cum[i + 1][j+1] = cum[i + 1][j ] + dp[i + 1][j]; cum[i + 1][j+1] %= MOD; } } ll ans = 0; REP(j, K + 1){ ans = add(ans,dp[N][j]); } print(ans); }