///
/// I have a dream and a piano
///
#define _USE_MATH_DEFINES
#define FAST ios::sync_with_stdio(false),cin.tie(0);
#include <bits/stdc++.h>
#define Loop(x, l, r) for(int x = (l); x < (r); ++x)
#define LoopR(x, l, r) for(int x = (r)-1; x >= (l); --x)
#define all(x) x.begin(), x.end()
#define Kill(x) exit((cout << (x) << '\n', 0))
#define YN(flag) ((flag)? "YES": "NO")
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> pii;
typedef std::pair<ll ,ll > pll;
using namespace std;
const int N = 105;
const int L = 1005;
const int mod = 1e9 + 7;
ll dp1[N][L][3];
ll dp2[N][L][3];
int a[N];
int n, l;
int main()
{
FAST;
cin >> n >> l;
Loop(i,0,n) cin >> a[i];
sort(a, a+n);
dp1[0][0][0] = 1;
Loop(i,0,n)
{
Loop(k,0,N)
Loop(l,0,L)
Loop(r,0,3)
{
ll x = i? a[i] - a[i-1]: a[0];
x = (2*k - r)*x + l;
if(x < 0 || x >= L) continue;
if(k > 0) dp2[k-1][x][r] += (k-1) * dp1[k][l][r];
if(true) dp2[k][x][r] += (2*k-r) * dp1[k][l][r];
if(r+!k < 2) dp2[k+!k][x][r+1+!k] += (2-r-!k) * dp1[k][l][r];
if(r < 2 && k < N-1) dp2[k+1][x][r+1] += (2-r) * dp1[k][l][r];
if(k < N-1) dp2[k+1][x][r] += (k+1-r) * dp1[k][l][r];
}
Loop(k,0,N)
Loop(l,0,L)
Loop(r,0,3)
dp1[k][l][r] = dp2[k][l][r] % mod,
dp2[k][l][r] = 0;
}
ll ans = 0;
Loop(i,0,l+1)
ans += dp1[1][i][2];
cout << ans%mod << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
5196 KB |
Output is correct |
2 |
Correct |
10 ms |
5196 KB |
Output is correct |
3 |
Correct |
18 ms |
5272 KB |
Output is correct |
4 |
Correct |
20 ms |
5264 KB |
Output is correct |
5 |
Correct |
16 ms |
5264 KB |
Output is correct |
6 |
Correct |
16 ms |
5272 KB |
Output is correct |
7 |
Correct |
20 ms |
5280 KB |
Output is correct |
8 |
Correct |
42 ms |
5196 KB |
Output is correct |
9 |
Correct |
19 ms |
5276 KB |
Output is correct |
10 |
Correct |
33 ms |
5192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
5248 KB |
Output is correct |
2 |
Correct |
54 ms |
5252 KB |
Output is correct |
3 |
Correct |
85 ms |
5248 KB |
Output is correct |
4 |
Correct |
57 ms |
5248 KB |
Output is correct |
5 |
Correct |
61 ms |
5248 KB |
Output is correct |
6 |
Correct |
66 ms |
5196 KB |
Output is correct |
7 |
Correct |
79 ms |
5248 KB |
Output is correct |
8 |
Correct |
82 ms |
5248 KB |
Output is correct |
9 |
Correct |
82 ms |
5260 KB |
Output is correct |
10 |
Correct |
57 ms |
5196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
5196 KB |
Output is correct |
2 |
Correct |
10 ms |
5196 KB |
Output is correct |
3 |
Correct |
18 ms |
5272 KB |
Output is correct |
4 |
Correct |
20 ms |
5264 KB |
Output is correct |
5 |
Correct |
16 ms |
5264 KB |
Output is correct |
6 |
Correct |
16 ms |
5272 KB |
Output is correct |
7 |
Correct |
20 ms |
5280 KB |
Output is correct |
8 |
Correct |
42 ms |
5196 KB |
Output is correct |
9 |
Correct |
19 ms |
5276 KB |
Output is correct |
10 |
Correct |
33 ms |
5192 KB |
Output is correct |
11 |
Correct |
74 ms |
5248 KB |
Output is correct |
12 |
Correct |
54 ms |
5252 KB |
Output is correct |
13 |
Correct |
85 ms |
5248 KB |
Output is correct |
14 |
Correct |
57 ms |
5248 KB |
Output is correct |
15 |
Correct |
61 ms |
5248 KB |
Output is correct |
16 |
Correct |
66 ms |
5196 KB |
Output is correct |
17 |
Correct |
79 ms |
5248 KB |
Output is correct |
18 |
Correct |
82 ms |
5248 KB |
Output is correct |
19 |
Correct |
82 ms |
5260 KB |
Output is correct |
20 |
Correct |
57 ms |
5196 KB |
Output is correct |
21 |
Correct |
234 ms |
5248 KB |
Output is correct |
22 |
Correct |
454 ms |
5252 KB |
Output is correct |
23 |
Correct |
341 ms |
5196 KB |
Output is correct |
24 |
Correct |
443 ms |
5252 KB |
Output is correct |
25 |
Correct |
351 ms |
5196 KB |
Output is correct |
26 |
Correct |
370 ms |
5248 KB |
Output is correct |
27 |
Correct |
578 ms |
5268 KB |
Output is correct |
28 |
Correct |
574 ms |
5196 KB |
Output is correct |
29 |
Correct |
538 ms |
5252 KB |
Output is correct |
30 |
Correct |
333 ms |
5252 KB |
Output is correct |