#aising2019d. [aising2019_d]Nearest Card Game
[aising2019_d]Nearest Card Game
Problem Statement
There are cards. The -th card has an integer written on it. For any two cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
- Aoki chooses an integer .
- Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
- Takahashi should take the card with the largest integer among the remaining card.
- Aoki should take the card with the integer closest to among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
- The game ends when there is no card remaining.
You are given candidates for the value of : . For each (), find the sum of the integers written on the cards that Takahashi will take if Aoki chooses .
Constraints
- ()
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line () should contain the answer for .
Sample Input 1
5 5
3 5 7 11 13
1
4
9
10
13
Sample Output 1
31
31
27
23
23
For example, when , the game proceeds as follows:
- Takahashi takes the card with .
- Aoki takes the card with .
- Takahashi takes the card with .
- Aoki takes the card with .
- Takahashi takes the card with .
Thus, should be printed on the third line.
Sample Input 2
4 3
10 20 30 40
2
34
34
Sample Output 2
70
60
60