제출 #168845

#제출 시각아이디문제언어결과실행 시간메모리
168845srvltSkyscraper (JOI16_skyscraper)C++14
5 / 100
123 ms125664 KiB
#include <bits/stdc++.h> #define ll long long #define db double #define pb push_back #define fi first #define se second #define mp make_pair #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define endl "\n" //#define int long long using namespace std; const int N = 103, K = 1003, MOD = 1e9 + 7; int n, r, a[N], dp[N][N][K][3]; void add(int & x, int y) { x += y; if (x >= MOD) { x %= MOD; } } int calc(int i, int j, int k, int l) { if (i > 0 && (j < 1 || l > 2 || k > r)) { return 0; } if (i == n) { return j == 1 && l == 2; } int & res = dp[i][j][k][l]; if (res != -1) { return res; } int s = (a[i + 1] - a[i]) * (2 * j - l) + k; res = 0; add(res, (j + 1 - l) * calc(i + 1, j + 1, s, l)); add(res, (2 - l) * calc(i + 1, j, s, l + 1)); add(res, (2 - l) * calc(i + 1, j + 1, s, l + 1)); add(res, (j - 1) * calc(i + 1, j - 1, s, l)); add(res, (2 * j - l) * calc(i + 1, j, s, l)); return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); memset(dp, -1, sizeof(dp)); cin >> n >> r; for (int i = 1; i <= n; i++) { cin >> a[i]; } if (n == 1) { cout << 1; return 0; } sort(a + 1, a + n + 1); a[0] = a[1]; cout << calc(0, 0, 0, 0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...