D. 总重压制 / Outweigh

    传统题 2000ms 256MiB

总重压制 / Outweigh

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

There are NN types of stones, 1,2,…,N1,2,\dots,N. Stones of the same type all have the same weight. Takahashi and Aoki have AiA_i and BiB_i stones of type ii, respectively. Determine whether there exists a sequence of positive integers W=(W1,W2,…,WN)W=(W_1,W_2,\dots,W_N) satisfying the following conditions, and if it exists, construct one such sequence.

  • 1≤Wi≤10181 \leq W_i \leq 10^{18}
  • If the weight of a type-ii stone is WiW_i, the total weight of the stones Takahashi has is strictly greater than the total weight of the stones Aoki has.

Constraints

  • 1≤N≤1051 \leq N \leq 10^5
  • 1≤Ai≤1091 \leq A_i \leq 10^9
  • 1≤Bi≤1091 \leq B_i \leq 10^9
  • All input values are integers.

Input

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

  • NN
  • A1A_1 A2A_2 …\dots ANA_N
  • B1B_1 B2B_2 …\dots BNB_N

Output

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

  • Yes
  • W1W_1 W2W_2 …\dots WNW_N

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

3
4 7 4
5 5 5
Yes
4 7 4

If W=(4,7,4)W=(4,7,4), the total weight of the stones Takahashi has is 4×4+7×7+4×4=814 \times 4 + 7 \times 7 + 4 \times 4=81. The total weight of the stones Aoki has is 4×5+7×5+4×5=754 \times 5 + 7 \times 5 + 4 \times 5=75.

3
3 3 3
4 7 4
No
1
2
2
No

ABC474 赛后模拟赛 ✅

未参加
状态
已结束
规则
IOI
题目
7
开始于
2026-9-6 14:00
结束于
2026-9-20 14:00
持续时间
336 小时
主持人
参赛人数
59