問題一覧 > 通常問題

No.2008 Super Worker

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 156
作問者 : Kiri8128 / テスター : 👑 Kazun
お気に入りにしたユーザー ProblemId : 6901 / 自分の提出
問題文最終更新日: 2022-07-19 23:52:17
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 352 (順位表) の他の問題:

Problem Statement

Kiri has a part-time job. Initially, Kiri's job level is $1$. There are $N$ jobs, and she has decided to take on all of them in any order she likes. If she does the $i\ (1 \le i \le N)$-th job when her job level is $x$, she receives a salary of $A_i \cdot x$, and then her job level becomes $B_i \cdot x$. What is the maximum possible total salary she can earn? Output the answer modulo $10^9+7$.

Input

$N$
$A_1\ A_2\ \cdots A_N$
$B_1\ B_2\ \cdots B_N$

$1 \le N \le 2 \times 10^5$
$1 \le A_i,\ B_i \le 10^6\ (1 \le i \le N)$
All inputs are integers.

Output

Output the maximum possible total salary modulo $10^9+7$.
Print a newline at the end.

Sample

Sample 1
Input
2
30 20
2 3
Output
110

[If job $1$ is done first]
 She can earn $30$ from job $1$ and $40$ from job $2$, for a total salary of $70$.

[If job $2$ is done first]
 She can earn $20$ from job $2$ and $90$ from job $1$, for a total salary of $110$.

Therefore, the maximum amount she can earn is $110$.

Sample 2
Input
2
7000 1000000
1000000 1
Output
0

Note that you must output the remainder modulo $10^9+7$.

Sample 3
Input
8
3 14 15 92 65 35 89 79
2 7 1 8 2 8 1 8
Output
2048669

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