AtCoder Beginner Contest 332
翻译中…
Problem Statement
翻译中…
There are several balls. Each ball is one of the colors $1$, $2$, $\ldots$, $N$, and for each $i = 1, 2, \ldots, N$, there are $A_i$ balls of color $i$.
翻译中…
Additionally, there are $M$ boxes. For each $j = 1, 2, \ldots, M$, the $j$-th box can hold up to $B_j$ balls in total.
翻译中…
Here, for all pairs of integers $(i, j)$ satisfying $1 \leq i \leq N$ and $1 \leq j \leq M$, the $j$-th box may hold at most $(i \times j)$ balls of color $i$.
翻译中…
Print the maximum total number of balls that the $M$ boxes can hold.
翻译中…
Constraints
翻译中…
- All input values are integers.
$1 \leq N \leq 500$$1 \leq M \leq 5 \times 10^5$$0 \leq A_i, B_i \leq 10^{12}$
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N M
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_M
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
2 3
8 10
4 3 8
Output #1
14
You can do as follows to put a total of $14$ balls into the boxes while satisfying the conditions in the problem statement.
- For balls of color $1$, put one into the first box, one into the second box, and three into the third box.
- For balls of color $2$, put two into the first box, two into the second box, and five into the third box.
Input #2
1 1
1000000000000
0
Output #2
0
Input #3
10 12
59 168 130 414 187 236 330 422 31 407
495 218 351 105 351 414 198 230 345 297 489 212
Output #3
2270
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。