#P15870. 【MX-X26-T6】「Cfz Round 7」vivi
【MX-X26-T6】「Cfz Round 7」vivi
Background
こんな話など 忘れておくれ / Please forget stories like this.
言いたいことは 一つもないさ / There is not a single thing I want to say.
Problem Description
In a shop, there are "fishies" lined up in a row. The volume of the -th "fishy" is .
Yuki has a backpack with volume . She plans to consider the "fishies" from to in order: if the current "fishy"'s volume is less than or equal to the remaining volume of the backpack, she puts this "fishy" into the backpack; otherwise, she does not. When a "fishy" with volume is put into the backpack, the remaining volume of the backpack decreases by .
Since Yuki is a magical girl, she can choose the initial volume of the backpack to be any non-negative integer, but she will not change the backpack's volume while considering the "fishies".
Let denote the selection status of the -th "fishy". Specifically, if the -th "fishy" is put into the backpack then , otherwise . You need to compute how many different sequences can be generated by the strategy above.
Input Format
The first line contains an integer , indicating the subtask index of this test point. The samples satisfy .
The second line contains an integer .
The third line contains integers .
Output Format
Output one line containing a non-negative integer, representing the number of different sequences that can be generated.
0
3
1 3 8
4
0
4
1 3 1 4
6
0
5
16 8 4 2 1
32
0
6
7 4 4 6 8 7
9
Hint
Sample 1 Explanation
- When the initial backpack volume , .
- When the initial backpack volume , .
- When the initial backpack volume , .
- When the initial backpack volume , .
It is easy to prove that when the initial backpack volume is any other non-negative integer, the generated must be one of these sequences, so the answer is .
Sample 2 Explanation
- When the initial backpack volume , .
- When the initial backpack volume , .
- When the initial backpack volume , .
- When the initial backpack volume , .
- When the initial backpack volume , .
- When the initial backpack volume , .
It is easy to prove that when the initial backpack volume is any other non-negative integer, the generated must be one of these sequences, so the answer is .
Constraints
For all testdata:
- .
- For all , .
This problem uses bundled tests.
- Subtask 1 (7 points): .
- Subtask 2 (11 points): ; for all , .
- Subtask 3 (8 points): ; for all , .
- Subtask 4 (5 points): .
- Subtask 5 (12 points): ; for all , .
- Subtask 6 (15 points): .
- Subtask 7 (13 points): .
- Subtask 8 (12 points): the sequence is guaranteed to be non-increasing.
- Subtask 9 (17 points): no special constraints.
Translated by ChatGPT 5