-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path179C.cpp
88 lines (81 loc) · 1.66 KB
/
179C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <iostream>
#include <algorithm>
#include <vector>
#define MOD 1000000007
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#define ll long long
#include <cmath>
#include <cstdlib>
#include <ctime>
#define exit return 0
using namespace std;
int N, a, b, c, m;
int K;
int won[55];
ll go[222][55][55];//50,100,boatid
int fix[5555];
ll C[55][55];
int ax[5555];
vector<int>gr[5555];
void binom(){
for (int i = 0; i < 54; i++){
for (int j = 0; j < 54; j++){
if (i == 0 || i == j){
C[i][j] = 1;
}
else{
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
}
}
}
}
int pirveli, meore;
int main(){
binom();
scanf("%d %d", &N, &K);
for (int i = 0; i < N; i++){
scanf("%d", &a);
if (a == 50)pirveli++; else meore++;
}
int X;
go[0][pirveli][meore] = 1;
for (X = 0; X <= 210; X++){
for (int i = 0; i <= pirveli; i++){
for (int j = 0; j <= meore; j++){
ll tmp = go[X][i][j];
for (int di = 0; di <= i; di++){
for (int dj = 0; dj <= j; dj++){
if (di == 0 && dj == 0)continue;
if (50 * di + 100 * dj > K)continue;
int axP = pirveli - (i - di);
int axM = meore - (j - dj);
go[X + 1][axP][axM] += (((C[i][di] % MOD) * (C[j][dj] % MOD) * tmp%MOD) % MOD) % MOD;
go[X + 1][axP][axM] %= MOD;
}
}
}
}
if ((X + 1) % 2 == 1 && go[X + 1][pirveli][meore]){
printf("%d\n", X + 1);
printf("%I64d\n", go[X + 1][pirveli][meore]);
exit;
}
}
printf("-1\n");
printf("0\n");
exit;
}