Submission #706531

# Submission time Handle Problem Language Result Execution time Memory
706531 2023-03-07T00:41:26 Z Username4132 Magneti (COCI21_magneti) C++14
110 / 110
129 ms 96472 KB
#include<iostream>
#include<algorithm>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
using ll = long long;

const int MAXN=10010, MOD=1e9+7;
int n, l, arr[53], dp[52][52][MAXN], ans;

ll ex(ll b, int e){
    int ret=1;
    while(e){
        if(e&1) ret = (ret*b)%MOD;
        b = (b*b)%MOD;
        e>>=1;
    }
    return ret;
}

inline int inv(int x){
    return ex(x, MOD-2);
}

int main(){
    scanf("%d %d", &n, &l);
    forn(i, n) scanf("%d", &arr[i]);
    sort(arr, arr+n);

    dp[0][0][0]=1;
    forn(i, n-1) forn(j, n) forn(sum, l+1){
        dp[i+1][j][sum] = (((ll) j+1)*(j>0? dp[i][j-1][sum] : 0) +
        2*((ll) j+1)*(sum>=arr[i+1]? dp[i][j][sum-arr[i+1]] : 0) +
        ((ll)j+1)*(sum>=2*arr[i+1]? dp[i][j+1][sum-2*arr[i+1]] : 0))%MOD;
    }
    ll comb=1;
    forn(i, l){
        ans = (ans + dp[n-1][0][l-1-i]*comb)%MOD;
        comb = (comb*(n+i+1))%MOD;
        comb = (comb*inv(i+1))%MOD;
    }
    printf("%d\n", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d %d", &n, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:26:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     forn(i, n) scanf("%d", &arr[i]);
      |                ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 119 ms 96460 KB Output is correct
2 Correct 5 ms 10708 KB Output is correct
3 Correct 6 ms 4276 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 7 ms 6868 KB Output is correct
6 Correct 34 ms 29872 KB Output is correct
7 Correct 60 ms 56968 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 26 ms 27692 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3904 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 6 ms 3796 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 6 ms 3896 KB Output is correct
6 Correct 2 ms 948 KB Output is correct
7 Correct 6 ms 3900 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4820 KB Output is correct
2 Correct 2 ms 2132 KB Output is correct
3 Correct 3 ms 4820 KB Output is correct
4 Correct 2 ms 2516 KB Output is correct
5 Correct 3 ms 4864 KB Output is correct
6 Correct 1 ms 1748 KB Output is correct
7 Correct 3 ms 4932 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 96460 KB Output is correct
2 Correct 5 ms 10708 KB Output is correct
3 Correct 6 ms 4276 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 7 ms 6868 KB Output is correct
6 Correct 34 ms 29872 KB Output is correct
7 Correct 60 ms 56968 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 26 ms 27692 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 6 ms 3904 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 6 ms 3796 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 6 ms 3896 KB Output is correct
16 Correct 2 ms 948 KB Output is correct
17 Correct 6 ms 3900 KB Output is correct
18 Correct 2 ms 980 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 4 ms 4820 KB Output is correct
22 Correct 2 ms 2132 KB Output is correct
23 Correct 3 ms 4820 KB Output is correct
24 Correct 2 ms 2516 KB Output is correct
25 Correct 3 ms 4864 KB Output is correct
26 Correct 1 ms 1748 KB Output is correct
27 Correct 3 ms 4932 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 2388 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 121 ms 96408 KB Output is correct
32 Correct 94 ms 66680 KB Output is correct
33 Correct 111 ms 96412 KB Output is correct
34 Correct 27 ms 21888 KB Output is correct
35 Correct 112 ms 96428 KB Output is correct
36 Correct 8 ms 5972 KB Output is correct
37 Correct 129 ms 96464 KB Output is correct
38 Correct 22 ms 24580 KB Output is correct
39 Correct 121 ms 96408 KB Output is correct
40 Correct 35 ms 29976 KB Output is correct
41 Correct 115 ms 96404 KB Output is correct
42 Correct 1 ms 948 KB Output is correct
43 Correct 121 ms 96444 KB Output is correct
44 Correct 12 ms 10460 KB Output is correct
45 Correct 111 ms 96472 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 30 ms 31572 KB Output is correct
48 Correct 15 ms 18492 KB Output is correct
49 Correct 3 ms 1748 KB Output is correct
50 Correct 1 ms 852 KB Output is correct