///
/// 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 >= 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 |
6 ms |
5196 KB |
Output is correct |
2 |
Correct |
11 ms |
5324 KB |
Output is correct |
3 |
Correct |
17 ms |
5196 KB |
Output is correct |
4 |
Correct |
18 ms |
5268 KB |
Output is correct |
5 |
Runtime error |
9 ms |
10444 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
5248 KB |
Output is correct |
2 |
Correct |
53 ms |
5248 KB |
Output is correct |
3 |
Correct |
81 ms |
5248 KB |
Output is correct |
4 |
Correct |
57 ms |
5196 KB |
Output is correct |
5 |
Correct |
61 ms |
5176 KB |
Output is correct |
6 |
Correct |
67 ms |
5260 KB |
Output is correct |
7 |
Correct |
77 ms |
5196 KB |
Output is correct |
8 |
Correct |
83 ms |
5252 KB |
Output is correct |
9 |
Correct |
82 ms |
5256 KB |
Output is correct |
10 |
Correct |
60 ms |
5196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
5196 KB |
Output is correct |
2 |
Correct |
11 ms |
5324 KB |
Output is correct |
3 |
Correct |
17 ms |
5196 KB |
Output is correct |
4 |
Correct |
18 ms |
5268 KB |
Output is correct |
5 |
Runtime error |
9 ms |
10444 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |