# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
448682 | ymm | Skyscraper (JOI16_skyscraper) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///
/// 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;
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';
}