AT_abc474_d.Outweigh

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

共有 NN 种石头,编号为 1,2,…,N1,2,\dots,N。同种石头的重量均相同。
高桥和青木分别拥有类型 ii 的石头 AiA_i 个和 BiB_i 个。
判断是否存在一个正整数序列 W=(W1,W2,…,WN)W=(W_1,W_2,\dots,W_N) 满足以下条件;若存在,请构造出这样一个序列。

  • 1≤Wi≤10181 \leq W_i \leq 10^{18}
  • 若类型 ii 的石头重量为 WiW_i,则高桥所拥有的石头总重量严格大于青木所拥有的石头总重量。

输入格式

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

NN
A1A_1 A2A_2 …\ldots ANA_N
B1B_1 B2B_2 …\ldots BNB_N

输入从标准输入中按以下格式给出:

NN
A1A_1 A2A_2 …\ldots ANA_N
B1B_1 B2B_2 …\ldots BNB_N

输出格式

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 …\ldots 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.

如果存在满足条件的 W=(W1,W2,…,WN)W=(W_1,W_2,\dots,W_N),则按以下格式输出:

Yes
W1W_1 W2W_2 …\ldots WNW_N

如果不存在满足条件的 W=(W1,W2,…,WN)W=(W_1,W_2,\dots,W_N),则在一行中输出 No。

输入输出样例

  • 输入#1

    3
    4 7 4
    5 5 5

    输出#1

    Yes
    4 7 4
  • 输入#2

    3
    3 3 3
    4 7 4

    输出#2

    No
  • 输入#3

    1
    2
    2

    输出#3

    No

说明/提示

Sample 1 Explanation:
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.

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.

样例 1 解释:
若 W=(4,7,4)W=(4,7,4),
则高桥所持石子的总重量为 4×4+7×7+4×4=814 \times 4 + 7 \times 7 + 4 \times 4 = 81。
而青木所持石子的总重量为 4×5+7×5+4×5=754 \times 5 + 7 \times 5 + 4 \times 5 = 75。

限制条件

  • 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
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页