Submission #772189

# Submission time Handle Problem Language Result Execution time Memory
772189 2023-07-03T17:50:13 Z ttamx Skyscraper (JOI16_skyscraper) C++14
100 / 100
178 ms 105392 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=105;
const int M=1005;
const int mod=1e9+7;

int n,l;
int a[N];
ll dp[N][N][M][4];
ll ans;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> l;
    for(int i=1;i<=n;i++)cin >> a[i];
    if(n==1)cout << 1,exit(0);
    sort(a+1,a+n+1);
    dp[1][1][0][0]=1;
    dp[1][1][0][1]=2;
    for(int i=2;i<=n;i++){
        for(int j=1;j<i;j++){
            for(int k=0;k<=l;k++){
                for(int e=0;e<3;e++){
                    int res=k+(a[i]-a[i-1])*(2*j-e);
                    if(res>l)continue;
                    dp[i][j-1][res][e]+=dp[i-1][j][k][e]*(j-1)%mod;
                    dp[i][j-1][res][e]%=mod;
                    dp[i][j][res][e]+=dp[i-1][j][k][e]*(2*j-e)%mod;
                    dp[i][j][res][e]%=mod;
                    dp[i][j+1][res][e]+=dp[i-1][j][k][e]*(j+1-e)%mod;
                    dp[i][j+1][res][e]%=mod;
                    dp[i][j][res][e+1]+=dp[i-1][j][k][e]*(2-e)%mod;
                    dp[i][j][res][e+1]%=mod;
                    dp[i][j+1][res][e+1]+=dp[i-1][j][k][e]*(2-e)%mod;
                    dp[i][j+1][res][e+1]%=mod;
                }
            }
        }
    }
    for(int i=0;i<=l;i++){
        ans+=dp[n][1][i][2];
        ans%=mod;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 1364 KB Output is correct
6 Correct 1 ms 1136 KB Output is correct
7 Correct 1 ms 584 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 1360 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 2 ms 980 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 2 ms 972 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 1096 KB Output is correct
10 Correct 1 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 1364 KB Output is correct
6 Correct 1 ms 1136 KB Output is correct
7 Correct 1 ms 584 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 1360 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 2 ms 980 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 2 ms 972 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 1096 KB Output is correct
20 Correct 1 ms 844 KB Output is correct
21 Correct 3 ms 3660 KB Output is correct
22 Correct 142 ms 87664 KB Output is correct
23 Correct 171 ms 104236 KB Output is correct
24 Correct 153 ms 99088 KB Output is correct
25 Correct 170 ms 105280 KB Output is correct
26 Correct 165 ms 96160 KB Output is correct
27 Correct 71 ms 50656 KB Output is correct
28 Correct 81 ms 59616 KB Output is correct
29 Correct 148 ms 94512 KB Output is correct
30 Correct 178 ms 105392 KB Output is correct