No.1066 #Various Colors / Red and Blue and more various colors (Easy)
タグ : / 解いたユーザー数 225
作問者 :
leafirby
/ テスター :
harady_a_human
Problem Statement
There are $N$ boxes here. The $i(1\leq i\leq N)$-th box contains $A_i$ balls.
More specifically, box $i$ contains exactly $1$ ball of each color from color $1$ to color $A_i$.
Answer $Q$ queries. The $i(1\leq i\leq Q)$-th query is as follows.
Input
$N\ Q$ $A_1\ A_2\ ...\ A_N$ $B_1\ B_2\ ...\ B_Q$
$1\le N\le 6000$
$1\le Q\le N+1$
$1\le A_i\le 2\times 10^5$
$0\le B_i\le N$
All inputs are integers.
Output
Answer the $Q$ queries, and print a newline at the end.
Sample
Sample 1
Input
3 4 3 4 5 0 1 2 3
Output
24 26 9 1
There are $60$ ways in total to take the balls. Among them, there are $24$ ways in which not even $1$ ball of color $1$ is included.
Sample 2
Input
4 3 1 3 3 3 3 1 4
Output
6 8 1
Sample 3
Input
3 2 5 7 5 1 3
Output
64 1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。