Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2)
F
Polycarp's problems
Codeforces
2300
原题
← E→
翻译中…

Polycarp is an experienced participant in Codehorses programming contests. Now he wants to become a problemsetter.

翻译中…

He sent to the coordinator a set of $*n*$ problems. Each problem has it's quality, the quality of the $*i*$-th problem is $*a*_{*i*}$ ($*a*_{*i*}$ can be positive, negative or equal to zero). The problems are ordered by expected difficulty, but the difficulty is not related to the quality in any way. The easiest problem has index $1$, the hardest problem has index $*n*$.

翻译中…

The coordinator's mood is equal to $*q*$ now. After reading a problem, the mood changes by it's quality. It means that after the coordinator reads a problem with quality $*b*$, the value $*b*$ is added to his mood. The coordinator always reads problems one by one from the easiest to the hardest, it's impossible to change the order of the problems.

翻译中…

If after reading some problem the coordinator's mood becomes negative, he immediately stops reading and rejects the problemset.

翻译中…

Polycarp wants to remove the minimum number of problems from his problemset to make the coordinator's mood non-negative at any moment of time. Polycarp is not sure about the current coordinator's mood, but he has $*m*$ guesses "the current coordinator's mood $*q* = *b*_{*i*}$".

翻译中…

For each of $*m*$ guesses, find the minimum number of problems Polycarp needs to remove so that the coordinator's mood will always be greater or equal to $0$ while he reads problems from the easiest of the remaining problems to the hardest.

翻译中…

Input

翻译中…

The first line of input contains two integers $*n*$ and $*m*$ ($1 ≤ *n* ≤ 750$, $1 ≤ *m* ≤ 200 000$) — the number of problems in the problemset and the number of guesses about the current coordinator's mood.

翻译中…

The second line of input contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($- 10^{9} ≤ *a*_{*i*} ≤ 10^{9}$) — the qualities of the problems in order of increasing difficulty.

翻译中…

The third line of input contains $*m*$ integers $*b*_{1}, *b*_{2}, ..., *b*_{*m*}$ ($0 ≤ *b*_{*i*} ≤ 10^{15}$) — the guesses of the current coordinator's mood $*q*$.

翻译中…

Output

翻译中…

Print $*m*$ lines, in $*i*$-th line print single integer — the answer to the problem with $*q* = *b*_{*i*}$.

翻译中…

样例

Input #1
6 3
8 -5 -4 1 -7 4
0 7 3
Output #1
2
0
1
InputCopy OutputCopy
题目信息
标签
二分
动态规划
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。