답안 #883078

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883078 2023-12-04T13:24:09 Z adaawf Skyscraper (JOI16_skyscraper) C++14
100 / 100
121 ms 220048 KB
#include <iostream>
#include <algorithm>
using namespace std;
long long int a[105], f[105][105][1005][3], mod = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    if (n == 1) {
        cout << 1;
        return 0;
    }
    sort(a + 1, a + n + 1);
    f[1][1][0][0] = 1;
    f[1][1][0][1] = 2;
    for (long long int i = 1; i < n; i++) {
        for (long long int j = 0; j <= i; j++) {
            for (long long int k = 0; k <= x; k++) {
                for (long long int l = 0; l <= 2; l++) {
                    f[i][j][k][l] %= mod;
                    if (f[i][j][k][l] == 0) continue;
                    long long int h = k + (a[i + 1] - a[i]) * (j * 2 - l);
                    if (h > x) continue;
                    if (j >= 2) f[i + 1][j - 1][h][l] += f[i][j][k][l] * (j - 1) % mod;
                    if (j >= 1) f[i + 1][j][h][l] += f[i][j][k][l] * (j * 2 - l) % mod;
                    if (l < 2) f[i + 1][j + 1][h][l + 1] += f[i][j][k][l] * (2 - l) % mod;
                    if (l < 2 && j >= 1) f[i + 1][j][h][l + 1] += f[i][j][k][l] * (2 - l) % mod;
                    f[i + 1][j + 1][h][l] += f[i][j][k][l] * (j + 1 - l) % mod;
                }
            }
        }
    }
    long long int res = 0;
    for (int i = 0; i <= x; i++) {
        res += f[n][1][i][2] % mod;
        res %= mod;
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 3 ms 18780 KB Output is correct
6 Correct 2 ms 18780 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 2 ms 18780 KB Output is correct
9 Correct 3 ms 18780 KB Output is correct
10 Correct 2 ms 18780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 29016 KB Output is correct
2 Correct 4 ms 33116 KB Output is correct
3 Correct 3 ms 33116 KB Output is correct
4 Correct 5 ms 33284 KB Output is correct
5 Correct 4 ms 33192 KB Output is correct
6 Correct 4 ms 33112 KB Output is correct
7 Correct 4 ms 33116 KB Output is correct
8 Correct 4 ms 33116 KB Output is correct
9 Correct 4 ms 33116 KB Output is correct
10 Correct 4 ms 33116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 3 ms 18780 KB Output is correct
6 Correct 2 ms 18780 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 2 ms 18780 KB Output is correct
9 Correct 3 ms 18780 KB Output is correct
10 Correct 2 ms 18780 KB Output is correct
11 Correct 3 ms 29016 KB Output is correct
12 Correct 4 ms 33116 KB Output is correct
13 Correct 3 ms 33116 KB Output is correct
14 Correct 5 ms 33284 KB Output is correct
15 Correct 4 ms 33192 KB Output is correct
16 Correct 4 ms 33112 KB Output is correct
17 Correct 4 ms 33116 KB Output is correct
18 Correct 4 ms 33116 KB Output is correct
19 Correct 4 ms 33116 KB Output is correct
20 Correct 4 ms 33116 KB Output is correct
21 Correct 23 ms 88880 KB Output is correct
22 Correct 105 ms 176272 KB Output is correct
23 Correct 117 ms 218296 KB Output is correct
24 Correct 112 ms 213948 KB Output is correct
25 Correct 119 ms 218964 KB Output is correct
26 Correct 121 ms 219844 KB Output is correct
27 Correct 51 ms 178516 KB Output is correct
28 Correct 59 ms 182952 KB Output is correct
29 Correct 97 ms 202864 KB Output is correct
30 Correct 121 ms 220048 KB Output is correct