CF1206A.Choose Two Numbers

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an array AA, consisting of nn positive integers a1,a2,…,ana_1, a_2, \dots, a_n, and an array BB, consisting of mm positive integers b1,b2,…,bmb_1, b_2, \dots, b_m.

Choose some element aa of AA and some element bb of BB such that a+ba+b doesn't belong to AA and doesn't belong to BB.

For example, if A=[2,1,7]A = [2, 1, 7] and B=[1,3,4]B = [1, 3, 4], we can choose 11 from AA and 44 from BB, as number 5=1+45 = 1 + 4 doesn't belong to AA and doesn't belong to BB. However, we can't choose 22 from AA and 11 from BB, as 3=2+13 = 2 + 1 belongs to BB.

It can be shown that such a pair exists. If there are multiple answers, print any.

Choose and print any such two numbers.

给你一个由 nn 个正整数 a1,a2,…,ana_1, a_2, \dots, a_n 组成的数组 AA,以及一个由 mm 个正整数 b1,b2,…,bmb_1, b_2, \dots, b_m 组成的数组 BB。

请从 AA 中选择某个元素 aa,从 BB 中选择某个元素 bb,使得 a+ba+b 既不属于 AA,也不属于 BB。

例如,若 A=[2,1,7]A = [2, 1, 7] 且 B=[1,3,4]B = [1, 3, 4],我们可以从 AA 中选择 11,从 BB 中选择 44,因为 5=1+45 = 1 + 4 既不在 AA 中,也不在 BB 中。然而,我们不能从 AA 中选择 22、从 BB 中选择 11,因为 3=2+13 = 2 + 1 属于 BB。

可以证明这样的数对一定存在。如果存在多个答案,输出任意一个即可。

请选出并输出这样两个数。

输入格式

The first line contains one integer nn (1≤n≤1001\le n \le 100) — the number of elements of AA.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤2001 \le a_i \le 200) — the elements of AA.

The third line contains one integer mm (1≤m≤1001\le m \le 100) — the number of elements of BB.

The fourth line contains mm different integers b1,b2,…,bmb_1, b_2, \dots, b_m (1≤bi≤2001 \le b_i \le 200) — the elements of BB.

It can be shown that the answer always exists.

第一行包含一个整数 nn(1≤n≤1001\le n \le 100)—— 表示集合 AA 的元素个数。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤2001 \le a_i \le 200)—— 表示集合 AA 的元素。

第三行包含一个整数 mm(1≤m≤1001\le m \le 100)—— 表示集合 BB 的元素个数。

第四行包含 mm 个互不相同的整数 b1,b2,…,bmb_1, b_2, \dots, b_m(1≤bi≤2001 \le b_i \le 200)—— 表示集合 BB 的元素。

可以证明答案一定存在。

输出格式

Output two numbers aa and bb such that aa belongs to AA, bb belongs to BB, but a+ba+b doesn't belong to nor AA neither BB.

If there are multiple answers, print any.

输出两个数 aa 和 bb,使得 a∈Aa \in A,b∈Bb \in B,但 a+ba+b 既不属于 AA 也不属于 BB。

若存在多个答案,输出任意一个即可。

输入输出样例

  • 输入#1

    1
    20
    2
    10 20

    输出#1

    20 20
  • 输入#2

    3
    3 2 2
    5
    1 5 7 7 9

    输出#2

    3 1
  • 输入#3

    4
    1 3 5 7
    4
    7 5 3 1

    输出#3

    1 1

说明/提示

In the first example, we can choose 2020 from array [20][20] and 2020 from array [10,20][10, 20]. Number 40=20+2040 = 20 + 20 doesn't belong to any of those arrays. However, it is possible to choose 1010 from the second array too.

In the second example, we can choose 33 from array [3,2,2][3, 2, 2] and 11 from array [1,5,7,7,9][1, 5, 7, 7, 9]. Number 4=3+14 = 3 + 1 doesn't belong to any of those arrays.

In the third example, we can choose 11 from array [1,3,5,7][1, 3, 5, 7] and 11 from array [7,5,3,1][7, 5, 3, 1]. Number 2=1+12 = 1 + 1 doesn't belong to any of those arrays.

在第一个例子中,我们可以从数组 [20][20] 中选择 2020,并从数组 [10,20][10, 20] 中选择 2020。数 40=20+2040 = 20 + 20 不属于其中任意一个数组。然而,也可以从第二个数组中选择 1010。

在第二个例子中,我们可以从数组 [3,2,2][3, 2, 2] 中选择 33,并从数组 [1,5,7,7,9][1, 5, 7, 7, 9] 中选择 11。数 4=3+14 = 3 + 1 不属于其中任意一个数组。

在第三个例子中,我们可以从数组 [1,3,5,7][1, 3, 5, 7] 中选择 11,并从数组 [7,5,3,1][7, 5, 3, 1] 中选择 11。数 2=1+12 = 1 + 1 不属于其中任意一个数组。

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

首页