301562: CF295C. Greg and Friends
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Greg and Friends
题意翻译
题意 有一个船最多能载K千克, 现在有n个人要过河, 船只有一条,每个人要么是50千克,要么是100千克,问有多少种方案可以到达河对岸,且来回次数最少? 先输出最少来回次数,再输出方案数,结果对10^9+7取模 无解输出 -1 0 感谢@hello_world2005 提供的翻译题目描述
One day Greg and his friends were walking in the forest. Overall there were $ n $ people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know that the boat can hold people with the total weight of at most $ k $ kilograms. Greg immediately took a piece of paper and listed there the weights of all people in his group (including himself). It turned out that each person weights either 50 or 100 kilograms. Now Greg wants to know what minimum number of times the boat needs to cross the river to transport the whole group to the other bank. The boat needs at least one person to navigate it from one bank to the other. As the boat crosses the river, it can have any non-zero number of passengers as long as their total weight doesn't exceed $ k $ . Also Greg is wondering, how many ways there are to transport everybody to the other side in the minimum number of boat rides. Two ways are considered distinct if during some ride they have distinct sets of people on the boat. Help Greg with this problem.输入输出格式
输入格式
The first line contains two integers $ n $ , $ k $ $ (1<=n<=50,1<=k<=5000) $ — the number of people, including Greg, and the boat's weight limit. The next line contains $ n $ integers — the people's weights. A person's weight is either $ 50 $ kilos or $ 100 $ kilos. You can consider Greg and his friends indexed in some way.
输出格式
In the first line print an integer — the minimum number of rides. If transporting everyone to the other bank is impossible, print an integer -1. In the second line print the remainder after dividing the number of ways to transport the people in the minimum number of rides by number $ 1000000007 $ $ (10^{9}+7) $ . If transporting everyone to the other bank is impossible, print integer $ 0 $ .
输入输出样例
输入样例 #1
1 50
50
输出样例 #1
1
1
输入样例 #2
3 100
50 50 100
输出样例 #2
5
2
输入样例 #3
2 50
50 50
输出样例 #3
-1
0