第 474 场 AtCoder Beginner Contest
D
更重
Outweigh
AtCoder
⌀ 389
原题
← BE →

更重AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

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.

有 $N$ 种石头,编号为 $1,2,\dots,N$。同一种石头的重量均相同。 Takahashi 和 Aoki 分别拥有 $A_i$ 块和 $B_i$ 块第 $i$ 种石头。 请判断是否存在满足以下条件的正整数序列 $W=(W_1,W_2,\dots,W_N)$,若存在,请构造一个这样的序列。AI (CI翻译)

  • $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.
  • $1 \leq W_i \leq 10^{18}$
  • 当第 $i$ 种石头的重量为 $W_i$ 时,Takahashi 拥有的石头的总重量严格大于 Aoki 拥有的石头的总重量。
AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $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.
  • $1 \leq N \leq 10^5$
  • $1 \leq A_i \leq 10^9$
  • $1 \leq B_i \leq 10^9$
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入通过标准输入以如下格式给出:AI (CI翻译)

N
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_N

N
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

If there exists $W=(W_1,W_2,\dots,W_N)$ satisfying the conditions, output it in the following format:

若存在满足条件的 $W=(W_1,W_2,\dots,W_N)$,请以如下格式输出:AI (CI翻译)

Yes
W_1 W_2 \ldots W_N

Yes
W_1 W_2 \ldots W_N
AI (CI翻译)

If there is no $W=(W_1,W_2,\dots,W_N)$ satisfying the conditions, output No in one line.

若不存在满足条件的 $W=(W_1,W_2,\dots,W_N)$,请在一行中输出 No。AI (CI翻译)

样例

Input #1
3
4 7 4
5 5 5
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$.
Input #2
3
3 3 3
4 7 4
Output #2
No
Input #3
1
2
2
Output #3
No
题目信息
题号
abc474_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。