Submission #854786

# Submission time Handle Problem Language Result Execution time Memory
854786 2023-09-29T00:49:28 Z wakandaaa Skyscraper (JOI16_skyscraper) C++17
20 / 100
159 ms 347576 KB
#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]);
    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 time Memory Grader output
1 Correct 40 ms 347220 KB Output is correct
2 Correct 36 ms 347216 KB Output is correct
3 Correct 37 ms 347216 KB Output is correct
4 Correct 37 ms 347220 KB Output is correct
5 Correct 38 ms 347216 KB Output is correct
6 Correct 37 ms 347220 KB Output is correct
7 Correct 37 ms 347216 KB Output is correct
8 Correct 37 ms 347220 KB Output is correct
9 Correct 37 ms 347220 KB Output is correct
10 Correct 37 ms 347220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 347220 KB Output is correct
2 Correct 37 ms 347192 KB Output is correct
3 Correct 37 ms 347224 KB Output is correct
4 Correct 41 ms 347472 KB Output is correct
5 Correct 37 ms 347216 KB Output is correct
6 Correct 39 ms 347576 KB Output is correct
7 Correct 40 ms 347220 KB Output is correct
8 Correct 37 ms 347216 KB Output is correct
9 Correct 37 ms 347396 KB Output is correct
10 Correct 38 ms 347220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 347220 KB Output is correct
2 Correct 36 ms 347216 KB Output is correct
3 Correct 37 ms 347216 KB Output is correct
4 Correct 37 ms 347220 KB Output is correct
5 Correct 38 ms 347216 KB Output is correct
6 Correct 37 ms 347220 KB Output is correct
7 Correct 37 ms 347216 KB Output is correct
8 Correct 37 ms 347220 KB Output is correct
9 Correct 37 ms 347220 KB Output is correct
10 Correct 37 ms 347220 KB Output is correct
11 Correct 37 ms 347220 KB Output is correct
12 Correct 37 ms 347192 KB Output is correct
13 Correct 37 ms 347224 KB Output is correct
14 Correct 41 ms 347472 KB Output is correct
15 Correct 37 ms 347216 KB Output is correct
16 Correct 39 ms 347576 KB Output is correct
17 Correct 40 ms 347220 KB Output is correct
18 Correct 37 ms 347216 KB Output is correct
19 Correct 37 ms 347396 KB Output is correct
20 Correct 38 ms 347220 KB Output is correct
21 Correct 38 ms 347228 KB Output is correct
22 Incorrect 159 ms 347412 KB Output isn't correct
23 Halted 0 ms 0 KB -