{"problem":{"name":"Nearest Card Game","description":{"content":"There are $N$ cards. The $i$\\-th card has an integer $A_i$ written on it. For any two cards, the integers on those cards are different. Using these cards, Takahashi and Aoki will play the following ga","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"aising2019_d"},"statements":[{"statement_type":"Markdown","content":"There are $N$ cards. The $i$\\-th card has an integer $A_i$ written on it. For any two cards, the integers on those cards are different.\nUsing these cards, Takahashi and Aoki will play the following game:\n\n*   Aoki chooses an integer $x$.\n*   Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:\n    *   Takahashi should take the card with the largest integer among the remaining card.\n    *   Aoki should take the card with the integer closest to $x$ among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.\n*   The game ends when there is no card remaining.\n\nYou are given $Q$ candidates for the value of $x$: $X_1, X_2, ..., X_Q$. For each $i$ ($1 \\leq i \\leq Q$), find the sum of the integers written on the cards that Takahashi will take if Aoki chooses $x = X_i$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 100$ $000$\n*   $1 \\leq Q \\leq 100$ $000$\n*   $1 \\leq A_1 < A_2 < ... < A_N \\leq 10^9$\n*   $1 \\leq X_i \\leq 10^9$ ($1 \\leq i \\leq Q$)\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $Q$\n$A_1$ $A_2$ $...$ $A_N$\n$X_1$\n$X_2$\n$:$\n$X_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"aising2019_d","tags":[],"sample_group":[["5 5\n3 5 7 11 13\n1\n4\n9\n10\n13","31\n31\n27\n23\n23\n\nFor example, when $x = X_3(= 9)$, the game proceeds as follows:\n\n*   Takahashi takes the card with $13$.\n*   Aoki takes the card with $7$.\n*   Takahashi takes the card with $11$.\n*   Aoki takes the card with $5$.\n*   Takahashi takes the card with $3$.\n\nThus, $13 + 11 + 3 = 27$ should be printed on the third line."],["4 3\n10 20 30 40\n2\n34\n34","70\n60\n60"]],"created_at":"2026-03-03 11:01:14"}}