#P6015. [CSGRound3] 游戏
[CSGRound3] 游戏
Description
There is a deck with a total of cards. The -th card has a number written on it, where the first card is the top of the deck.
Player Z draws first. He may draw a consecutive number of cards starting from the top of the deck (he may draw cards). The drawn cards are held in his hand, meaning they are removed from the deck.
Then Player Y draws. Similarly, she may draw a consecutive number of cards starting from the top of the deck (she may draw cards).
If the sum of the numbers on a player's hand is greater than , then their score is ; otherwise, their score equals the sum.
The player with the higher score wins; if the scores are equal, then nobody wins.
In order to win, Player Z uses a cheating tool (x-ray vision), meaning he knows the number written on every card in the deck.
Now, for all integers satisfying , determine which values of allow Player Z to have a winning strategy, i.e., after Player Z finishes drawing, no matter how Player Y draws, Player Y will definitely lose.
Input Format
The first line contains an integer , representing the number of cards in the deck.
The second line contains integers , representing the number written on each card.
The third line contains a positive integer , as described in the statement.
Output Format
The first line contains an integer, representing the number of values that satisfy the requirement.
The second line outputs the values of that satisfy the requirement in increasing order, separated by spaces.
5
1 4 3 2 2
5
3
1 2 3
Hint
[Sample Explanation]
When , Player Z draws one card, and no matter how Player Y draws, Player Y will get a score of .
When , if Player Z draws card, then if Player Y draws card, Player Y will win; otherwise, Player Z can only get a score of .
When , if Player Z draws card, then if Player Y draws card, Player Y will win. If Player Z draws cards, then Player Y also draws cards, resulting in a tie. Otherwise, Player Z can only get a score of .
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (3 points): .
- Subtask 2 (14 points): .
- Subtask 3 (20 points): .
- Subtask 4 (33 points): .
- Subtask 5 (30 points): no special restrictions.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号