답안 #678325

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
678325 2023-01-05T13:11:10 Z stevancv Skyscraper (JOI16_skyscraper) C++14
20 / 100
155 ms 5160 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sadd(a, b) a = Add(a, b)
#define smul(a, b) a = Mul(a, b)
using namespace std;
const int N = 100 + 2;
const int M = 1000 + 2;
const int mod = 1e9 + 7;
int Add(int a, int b) {
    a += b;
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}
int Mul(int a, int b) {
    ll c = a; c *= b; c %= mod;
    return c;
}
int dp[N][M][3], odp[N][M][3], a[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, l;
    cin >> n >> l;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (n == 1) {
        cout << 1 << en;
        return 0;
    }
    sort(a + 1, a + n + 1);
    if (a[2] - a[1] <= l) dp[1][a[2] - a[1]][1] = 2;
    if (2 * (a[2] - a[1]) <= l) dp[1][2 * (a[2] - a[1])][0] = 1;
    for (int i = 2; i <= n; i++) {
        int diff = a[i + 1] - a[i];
        for (int j = 1; j <= i; j++) {
            for (int s = 0; s <= l; s++) {
                for (int e = 0; e < 3; e++) {
                    odp[j][s][e] = dp[j][s][e];
                    dp[j][s][e] = 0;
                }
            }
        }
        for (int j = 1; j <= i; j++) {
            for (int s = 0; s <= l; s++) {
                for (int e = 0; e < 3; e++) {
                    int kol = 2 * j - e;
                    if (s < diff * kol) continue;
                    sadd(dp[j][s][e], Mul(j - e, odp[j - 1][s - diff * kol][e]));
                    sadd(dp[j][s][e], Mul(2 * j - e, odp[j][s - diff * kol][e]));
                    sadd(dp[j][s][e], Mul(j, odp[j + 1][s - diff * kol][e]));
                    if (e == 0) continue;
                    sadd(dp[j][s][e], Mul(3 - e, odp[j - 1][s - diff * kol][e - 1]));
                    sadd(dp[j][s][e], Mul(3 - e, odp[j][s - diff * kol][e - 1]));
                }
            }
        }
    }
    int ans = 0;
    for (int s = 0; s <= l; s++) sadd(ans, dp[1][s][2]);
    cout << ans << en;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 2 ms 452 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 2 ms 452 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 580 KB Output is correct
22 Correct 134 ms 2096 KB Output is correct
23 Runtime error 155 ms 5160 KB Execution killed with signal 11
24 Halted 0 ms 0 KB -