A12812 | Choose Two Numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given an array $A$ , consisting of $n$ positive integers $a_1, a_2, \dots, a_n$ , and an array $B$ , consisting of $m$ positive integers $b_1, b_2, \dots, b_m$ .
Choose some element $a$ of $A$ and some element $b$ of $B$ such that $a+b$ doesn't belong to $A$ and doesn't belong to $B$ .
For example, if $A = [2, 1, 7]$ and $B = [1, 3, 4]$ , we can choose $1$ from $A$ and $4$ from $B$ , as number $5 = 1 + 4$ doesn't belong to $A$ and doesn't belong to $B$ . However, we can't choose $2$ from $A$ and $1$ from $B$ , as $3 = 2 + 1$ belongs to $B$ .
It can be shown that such a pair exists. If there are multiple answers, print any.
Choose and print any such two numbers.
Choose some element $a$ of $A$ and some element $b$ of $B$ such that $a+b$ doesn't belong to $A$ and doesn't belong to $B$ .
For example, if $A = [2, 1, 7]$ and $B = [1, 3, 4]$ , we can choose $1$ from $A$ and $4$ from $B$ , as number $5 = 1 + 4$ doesn't belong to $A$ and doesn't belong to $B$ . However, we can't choose $2$ from $A$ and $1$ from $B$ , as $3 = 2 + 1$ belongs to $B$ .
It can be shown that such a pair exists. If there are multiple answers, print any.
Choose and print any such two numbers.
输入格式
The first line contains one integer $n$ ( $1\le n \le 100$ ) — the number of elements of $A$ .
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le 200$ ) — the elements of $A$ .
The third line contains one integer $m$ ( $1\le m \le 100$ ) — the number of elements of $B$ .
The fourth line contains $m$ different integers $b_1, b_2, \dots, b_m$ ( $1 \le b_i \le 200$ ) — the elements of $B$ .
It can be shown that the answer always exists.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le 200$ ) — the elements of $A$ .
The third line contains one integer $m$ ( $1\le m \le 100$ ) — the number of elements of $B$ .
The fourth line contains $m$ different integers $b_1, b_2, \dots, b_m$ ( $1 \le b_i \le 200$ ) — the elements of $B$ .
It can be shown that the answer always exists.
输出格式
Output two numbers $a$ and $b$ such that $a$ belongs to $A$ , $b$ belongs to $B$ , but $a+b$ doesn't belong to nor $A$ neither $B$ .
If there are multiple answers, print any.
If there are multiple answers, print any.
输入输出样例
输入 #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 $20$ from array $[20]$ and $20$ from array $[10, 20]$ . Number $40 = 20 + 20$ doesn't belong to any of those arrays. However, it is possible to choose $10$ from the second array too.
In the second example, we can choose $3$ from array $[3, 2, 2]$ and $1$ from array $[1, 5, 7, 7, 9]$ . Number $4 = 3 + 1$ doesn't belong to any of those arrays.
In the third example, we can choose $1$ from array $[1, 3, 5, 7]$ and $1$ from array $[7, 5, 3, 1]$ . Number $2 = 1 + 1$ doesn't belong to any of those arrays.
In the second example, we can choose $3$ from array $[3, 2, 2]$ and $1$ from array $[1, 5, 7, 7, 9]$ . Number $4 = 3 + 1$ doesn't belong to any of those arrays.
In the third example, we can choose $1$ from array $[1, 3, 5, 7]$ and $1$ from array $[7, 5, 3, 1]$ . Number $2 = 1 + 1$ doesn't belong to any of those arrays.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted