103442: [Atcoder]ABC344 C - A+B+C

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:19 Solved:0

Description

Score: $250$ points

Problem Statement

You are given three sequences $A=(A_1,\ldots,A_N)$, $B=(B_1,\ldots,B_M)$, and $C=(C_1,\ldots,C_L)$.

Additionally, a sequence $X=(X_1,\ldots,X_Q)$ is given. For each $i=1,\ldots,Q$, solve the following problem:

Problem: Is it possible to select one element from each of $A$, $B$, and $C$ so that their sum is $X_i$?

Constraints

  • $1 \leq N,M,L \leq 100$
  • $0 \leq A_i, B_i ,C_i \leq 10^8$
  • $1 \leq Q \leq 2\times 10^5$
  • $0 \leq X_i \leq 3\times 10^8$
  • All input values are integers.

Input

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

$N$
$A_1$ $\ldots$ $A_N$
$M$
$B_1$ $\ldots$ $B_M$
$L$ 
$C_1$ $\ldots$ $C_L$
$Q$
$X_1$ $\ldots$ $X_Q$

Output

Print $Q$ lines. The $i$-th line should contain Yes if it is possible to select one element from each of $A$, $B$, and $C$ so that their sum is $X_i$, and No otherwise.


Sample Input 1

3
1 2 3
2
2 4
6
1 2 4 8 16 32
4
1 5 10 50

Sample Output 1

No
Yes
Yes
No
  • It is impossible to select one element from each of $A$, $B$, and $C$ so that their sum is $1$.
  • Selecting $1$, $2$, and $2$ from $A$, $B$, and $C$, respectively, makes the sum $5$.
  • Selecting $2$, $4$, and $4$ from $A$, $B$, and $C$, respectively, makes the sum $10$.
  • It is impossible to select one element from each of $A$, $B$, and $C$ so that their sum is $50$.

Input

Output

分数:250分

问题描述

给你三个序列$A=(A_1,\ldots,A_N)$,$B=(B_1,\ldots,B_M)$和$C=(C_1,\ldots,C_L)$。

此外,还给出一个序列$X=(X_1,\ldots,X_Q)$。对于每个$i=1,\ldots,Q$,解决以下问题:

问题:是否可以从$A$,$B$和$C$中分别选择一个元素,使它们的和等于$X_i$?

限制条件

  • $1 \leq N,M,L \leq 100$
  • $0 \leq A_i, B_i ,C_i \leq 10^8$
  • $1 \leq Q \leq 2\times 10^5$
  • $0 \leq X_i \leq 3\times 10^8$
  • 所有输入值都是整数。

输入

输入从标准输入中给出,如下所示:

$N$
$A_1$ $\ldots$ $A_N$
$M$
$B_1$ $\ldots$ $B_M$
$L$ 
$C_1$ $\ldots$ $C_L$
$Q$
$X_1$ $\ldots$ $X_Q$

输出

打印$Q$行。 如果可以分别从$A$,$B$和$C$中选择一个元素,使它们的和等于$X_i$,则第$i$行应包含Yes,否则包含No


样例输入1

3
1 2 3
2
2 4
6
1 2 4 8 16 32
4
1 5 10 50

样例输出1

No
Yes
Yes
No
  • 无法分别从$A$,$B$和$C$中选择一个元素,使它们的和等于$1$。
  • 分别从$A$,$B$和$C$中选择$1$,$2$和$2$,使它们的和为$5$。
  • 分别从$A$,$B$和$C$中选择$2$,$4$和$4$,使它们的和为$10$。
  • 无法分别从$A$,$B$和$C$中选择一个元素,使它们的和等于$50$。

加入题单

算法标签: