AtCoder Regular Contest 200 (Div. 2)
A
Dot Product
AtCoder
⌀ 1821
原题
←B →
翻译中…

Problem Statement

翻译中…

You are given sequences of positive integers of length $N$: $A=(A_1,A_2,\ldots,A_N),B=(B_1,B_2,\ldots,B_N)$.

翻译中…

Determine whether there exists an integer sequence $X=(X_1,X_2,\ldots,X_N)$ that satisfies all the following conditions, and if it exists, find one.

翻译中…
  • $-10^8\le X_i\le 10^8$ $(1\le i\le N)$
  • $\displaystyle \sum_{i=1}^N A_iX_i > 0$
  • $\displaystyle \sum_{i=1}^N B_iX_i < 0$
翻译中…

You are given $T$ test cases, so find the answer for each.

翻译中…

Constraints

翻译中…
  • $1\le T\le 2\times 10^5$
  • $1\le N\le 2\times 10^5$
  • $1\le A_i,B_i\le 10^5$
  • The sum of $N$ over all test cases is at most $2\times 10^5$.
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

翻译中…

Each test case is given in the following format:

翻译中…

N
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_N

翻译中…

Output

翻译中…

Output your solutions for the test cases in order, separated by newlines.

翻译中…

For each test case, if there is no $X$ that satisfies all conditions, output No.

翻译中…

Otherwise, output an $X$ that satisfies all conditions in the following format:

翻译中…

Yes
X_1 X_2 \ldots X_N

翻译中…

If there are multiple $X$ that satisfy the conditions, you may output any of them.

翻译中…

样例

Input #1
3
3
3 1 4
1 5 1
3
4 4 4
7 7 7
4
20 25 6 15
31 41 59 26
Output #1
Yes
4 -5 1
No
Yes
45 -10 -40 11
For the first test case, if we set $X=(4,-5,1)$, then - $\displaystyle \sum_{i=1}^3 A_iX_i=3\times 4+1\times (-5)+4\times 1=11>0$ - $\displaystyle \sum_{i=1}^3 B_iX_i=1\times 4+5\times (-5)+1\times 1=-20<0$ which satisfies the conditions. Other examples that satisfy the conditions include $X=(3,-3,1)$ and $X=(27,-40,22)$.
题目信息
题号
arc200_a
时间限制
3 s
内存限制
1024 MB

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