Submission #3243706


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int N;
long long A[50];
long long K;
long long T[50], tsum;
long long dp0[51][4000];
long long dp1[51][4000];
const long long MOD = 1e9+7;

void add(long long&a, long long b){
    a = (a+b) % MOD;
}

int main(){
    long long i, j, k;
    cin >> N >> K;
    for(i=0; i<N; i++){
        cin >> A[i];
        long long a = A[i];
        while(a>0){
            T[i]++;
            a /= 2;
        }
        tsum += T[i];
    }
    dp1[0][0] = 1;
    for(i=0; i<N; i++){
        for(j=0; j<=tsum; j++){
            for(k=0; k<T[i]; k++){
                add(dp0[i+1][j+k], dp0[i][j]);
                add(dp1[i+1][j+k], dp1[i][j]);
            }
            k = T[i];
            add(dp0[i+1][j+k], dp0[i][j] + dp1[i][j]);
        }
    }

    long long ans = 0;
    if(K < tsum) add(ans, dp1[N][K]);
    for(j=0; j<=min(K, tsum); j++) add(ans, dp0[N][j]);
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task C - 半分
User betrue12
Language C++14 (GCC 5.4.1)
Score 500
Code Size 985 Byte
Status
Exec Time 32 ms
Memory 3072 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 500 / 500 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Case Name Status Exec Time Memory
01.txt 31 ms 2944 KB
02.txt 30 ms 2944 KB
03.txt 28 ms 2816 KB
04.txt 32 ms 2944 KB
05.txt 28 ms 2816 KB
06.txt 32 ms 3072 KB
07.txt 30 ms 2944 KB
08.txt 26 ms 2816 KB
09.txt 31 ms 2944 KB
10.txt 30 ms 2944 KB
11.txt 28 ms 2816 KB
12.txt 31 ms 2944 KB
13.txt 1 ms 256 KB
14.txt 1 ms 256 KB
15.txt 1 ms 256 KB
16.txt 10 ms 1792 KB
17.txt 10 ms 1792 KB
18.txt 11 ms 1920 KB
19.txt 9 ms 1792 KB
20.txt 13 ms 2048 KB
21.txt 11 ms 1920 KB
22.txt 10 ms 1920 KB
23.txt 10 ms 1792 KB
24.txt 11 ms 1920 KB
25.txt 9 ms 1792 KB
26.txt 9 ms 1792 KB
27.txt 10 ms 1920 KB
28.txt 24 ms 2688 KB
29.txt 24 ms 2688 KB
30.txt 1 ms 256 KB
31.txt 2 ms 896 KB
32.txt 2 ms 896 KB
sample-01.txt 1 ms 256 KB
sample-02.txt 1 ms 256 KB
sample-03.txt 1 ms 256 KB
sample-04.txt 2 ms 384 KB