Submission #854787

#TimeUsernameProblemLanguageResultExecution timeMemory
854787wakandaaaSkyscraper (JOI16_skyscraper)C++17
20 / 100
160 ms347472 KiB
#include <bits/stdc++.h> using namespace std; #define file "" #define mp make_pair #define fi first #define se second #define all(x) x.begin(), x.end() #define getbit(x, i) (((x) >> (i)) & 1) #define bit(x) (1LL << (x)) #define popcount __builtin_popcountll mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { return l + rd() % (r - l + 1); } const int N = 1e6 + 5; const int mod = (int)1e9 + 7; // 998244353; const int lg = 25; // lg + 1 const int oo = 1e9; const long long ooo = 1e18; template<class X, class Y> bool mini(X &a, Y b) { return a > b ? (a = b, true) : false; } template<class X, class Y> bool maxi(X &a, Y b) { return a < b ? (a = b, true) : false; } void add(int &a, int b) { a += b; if (a >= mod) a -= mod; if (a < 0) a += mod; } int n, L; int a[N]; long long f[105][105][1005][2][2]; long long calc(int i, int j, int s, int l, int r) { // int news = s + (j * 2 + l + r) * (a[i] - a[i - 1]); int news = s; if (i > 1) news += (j * 2 + l + r) * (a[i] - a[i - 1]); if (news > L) return 0; if (j < 0) return 0; if (i == n) return j == 0; long long &res = f[i][j][s][l][r]; if (res != -1) return res; res = 0; res += calc(i + 1, j, news, 1, r); // append to the left res += calc(i + 1, j - 1, news, 1, r) * j; // append to the left and merge res += calc(i + 1, j, news, l, 1); // append to the right res += calc(i + 1, j - 1, news, l, 1) * j; // append to the right and merge res += calc(i + 1, j + 1, news, l, r); // new one res += calc(i + 1, j, news, l, r) * j * 2; // append res += calc(i + 1, j - 1, news, l, r) * j * (j - 1); // merge return res % mod; } int main() { ios::sync_with_stdio(false); cin.tie(0); // freopen(file".inp", "r", stdin); // freopen(file".out", "w", stdout); cin >> n >> L; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + n + 1); a[0] = a[1]; memset(f, -1, sizeof f); cout << calc(1, 0, 0, 0, 0); return 0; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...