Submission #1029360

# Submission time Handle Problem Language Result Execution time Memory
1029360 2024-07-20T18:43:10 Z codefox Skyscraper (JOI16_skyscraper) C++17
20 / 100
408 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")

#define int long long
const int mod = 1e9 + 7;

int32_t main()
{
    int n, l;
    cin >> n >> l;
    if (n==1)
    {
        cout << 1;
        return 0;
    }
    vector<int> nums(n);
    for (int i = 0; i < n; i++)
    {
        cin >> nums[i];
    }
    sort(nums.begin(), nums.end());
    vector<vector<vector<vector<int>>>> dp(n+1, vector<vector<vector<int>>>(l+1, vector<vector<int>>(n+1, vector<int>(3, 0))));
    dp[1][0][1][0] = 1;
    dp[1][0][1][1] = 2;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j <= l; j++)
        {
            for (int k = 1; k <= i; k++)
            {
                for (int m =0; m < 3; m++)
                {
                    int nsum = j;
                    nsum = j+(k*2-m)*(nums[i]-nums[i-1]);
                    if(nsum > l) continue;
                    dp[i+1][nsum][k][m] += dp[i][j][k][m]*(k*2-m);
                    dp[i+1][nsum][k-1][m] += dp[i][j][k][m]*(k-1);
                    dp[i+1][nsum][k+1][m] += dp[i][j][k][m]*(k+1-m);
                    if(m!=2)
                    {
                        dp[i+1][nsum][k+1][m+1] += dp[i][j][k][m]*(2-m);
                        if(k) dp[i+1][nsum][k][m+1] += dp[i][j][k][m]*(2-m);
                        dp[i+1][nsum][k+1][m+1]%=mod;
                        dp[i+1][nsum][k][m+1]%=mod;
                    }
                    dp[i+1][nsum][k][m]%=mod;
                    dp[i+1][nsum][k-1][m]%=mod;
                    dp[i+1][nsum][k+1][m]%=mod;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i <= l; i++)
    {
        sum += dp[n][i][1][2];
        sum%=mod;
    }
    cout << sum;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 5 ms 5208 KB Output is correct
6 Correct 4 ms 4852 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 5 ms 4956 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 2 ms 1628 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 3 ms 1684 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 920 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 5 ms 5208 KB Output is correct
6 Correct 4 ms 4852 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 5 ms 4956 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 2 ms 1628 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 3 ms 1684 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 1 ms 1628 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 920 KB Output is correct
19 Correct 1 ms 1372 KB Output is correct
20 Correct 1 ms 1460 KB Output is correct
21 Correct 4 ms 4188 KB Output is correct
22 Correct 408 ms 287472 KB Output is correct
23 Runtime error 319 ms 524288 KB Execution killed with signal 9
24 Halted 0 ms 0 KB -