AtCoder Regular Contest 195 (Div. 2)
翻译中…
Problem Statement
翻译中…
There are two sequences $A=(A_1,\dots,A_N)$ and $B=(B_1,\dots,B_N)$. You can perform the following three types of operations any number of times in any order:
翻译中…
- Choose an index
$i$such that$A_i = -1$, and replace$A_i$with any non-negative integer. - Choose an index
$i$such that$B_i = -1$, and replace$B_i$with any non-negative integer. - Rearrange the elements of sequence
$A$in any order.
翻译中…
Determine whether it is possible, after these operations, for all elements of $A$ and $B$ to be non-negative and satisfy $A_1 + B_1 = A_2 + B_2 = \dots = A_N + B_N$.
翻译中…
Constraints
翻译中…
$2 \leq N \leq 2000$$-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 it is possible, after the operations, for all elements of $A$ and $B$ to be non-negative and satisfy $A_1 + B_1 = A_2 + B_2 = \dots = A_N + B_N$, print Yes. Otherwise, print No.
翻译中…
样例
Input #1
4
2 0 -1 3
3 -1 4 2
Output #1
Yes
Consider the following operations:
- Replace $A_3$ with $1$.
- Replace $B_2$ with $1$.
- Rearrange $A$ to $(1,3,0,2)$.
After these operations, $A = (1,3,0,2)$ and $B = (3,1,4,2)$: all elements of $A$ and $B$ are non-negative, and $A_1+B_1 = A_2+B_2 = A_3+B_3 = A_4+B_4 = 4$ is satisfied.
Input #2
3
1 2 3
1 2 4
Output #2
No
No matter how you perform the operations, it is impossible to satisfy $A_1+B_1 = A_2+B_2 = A_3+B_3$.
Input #3
3
1 2 -1
1 2 4
Output #3
No
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。