問題一覧 > 通常問題

No.1201 Candy Distribution-4

レベル : / AI推定難易度 : 1750 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 93
作問者 : PCTprobability / テスター : hotman78
お気に入りにしたユーザー ProblemId : 4783 / 自分の提出
問題文最終更新日: 2020-08-28 23:49:13
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 263 (順位表) の他の問題:

Problem Statement

You are given positive integers $N,M$. You are then given integer sequences $A_1,A_2,\ldots ,A_N$ and $B=B_1,B_2,\ldots ,B_M$ of lengths $N,M$. Let $C$ be the maximum value of the sequence $B$; there are $C$ children. These children are numbered $1,2,\ldots ,C $. There are $NM$ ways to choose one element from each of the sequences $A,B$, and the following operation is performed for all of them.

Let the chosen elements be $A_i,B_j$. For all children numbered from $1$ to $B_j$, the child numbered $k$ is given $2×\lfloor \frac{A_i×k}{B_j}\rfloor $ candies.

Output the minimum number of candies needed to perform all of these operations. Since the answer can be very large, output it modulo $1000000007$.

Input

$N$
$M$
$A_1\ A_2\ \dots\ A_N$
$B_1\ B_2\ \dots\ B_M$

  • All inputs are integers.
  • $1 \le N,M \le 2000=2×10^3$
  • $0 \le A_i\le 100000000=10^8$
  • $1 \le B_j\le 100000000=10^8$

Output

Output the minimum number of candies needed, modulo $1000000007$, followed by a newline.

Sample

Sample 1
Input
1
1
3
4
Output
12

  • Child $1$ is given $2×\lfloor \frac{3×1}{4}\rfloor=0 $ candies.
  • Child $2$ is given $2×\lfloor \frac{3×2}{4}\rfloor=2 $ candies.
  • Child $3$ is given $2×\lfloor \frac{3×3}{4}\rfloor=4 $ candies.
  • Child $4$ is given $2×\lfloor \frac{3×4}{4}\rfloor=6 $ candies.
In total, $0+2+4+6=12$ candies are needed.

Sample 2
Input
6
9
234523 35645 223 3563 234 346
346 467568 234141 457 235235 4656 3452 457 2
Output
792159237

Output the answer modulo $1000000007$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。