/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
N 種類の石 1,2,\dots,N があり、同じ種類の石の重みはすべて同じです。
高橋君と青木君は石 i をそれぞれ A_i,B_i 個ずつ持っています。
以下の条件を満たすような正整数列 W=(W_1,W_2,\dots,W_N) が存在するかどうかを判定し、存在するならば一つ構成してください。
- 1 \leq W_i \leq 10^{18}
- 石 i の重みが W_i のとき、高橋君が持っている石の重みの総和が青木君が持っている石の重みの総和よりも真に大きい。
制約
- 1 \leq N \leq 10^5
- 1 \leq A_i \leq 10^9
- 1 \leq B_i \leq 10^9
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N B_1 B_2 \ldots B_N
出力
条件を満たすような W=(W_1,W_2,\dots,W_N) が存在するならば以下の形式で出力せよ。
Yes W_1 W_2 \ldots W_N
条件を満たすような W=(W_1,W_2,\dots,W_N) が存在しないならば No を 1 行で出力せよ。
入力例 1
3 4 7 4 5 5 5
出力例 1
Yes 4 7 4
W=(4,7,4) のとき、
高橋君が持っている石の重みの総和は 4 \times 4 + 7 \times 7 + 4 \times 4=81 です。
青木君が持っている石の重みの総和は 4 \times 5 + 7 \times 5 + 4 \times 5=75 です。
入力例 2
3 3 3 3 4 7 4
出力例 2
No
入力例 3
1 2 2
出力例 3
No
Score : 400 points
Problem Statement
There are N types of stones, 1,2,\dots,N. Stones of the same type all have the same weight.
Takahashi and Aoki have A_i and B_i stones of type i, respectively.
Determine whether there exists a sequence of positive integers W=(W_1,W_2,\dots,W_N) satisfying the following conditions, and if it exists, construct one such sequence.
- 1 \leq W_i \leq 10^{18}
- If the weight of a type-i stone is W_i, the total weight of the stones Takahashi has is strictly greater than the total weight of the stones Aoki has.
Constraints
- 1 \leq N \leq 10^5
- 1 \leq A_i \leq 10^9
- 1 \leq B_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_N B_1 B_2 \ldots B_N
Output
If there exists W=(W_1,W_2,\dots,W_N) satisfying the conditions, output it in the following format:
Yes W_1 W_2 \ldots W_N
If there is no W=(W_1,W_2,\dots,W_N) satisfying the conditions, output No in one line.
Sample Input 1
3 4 7 4 5 5 5
Sample Output 1
Yes 4 7 4
If W=(4,7,4),
the total weight of the stones Takahashi has is 4 \times 4 + 7 \times 7 + 4 \times 4=81.
The total weight of the stones Aoki has is 4 \times 5 + 7 \times 5 + 4 \times 5=75.
Sample Input 2
3 3 3 3 4 7 4
Sample Output 2
No
Sample Input 3
1 2 2
Sample Output 3
No