A11274 | Rudolf and the Ticket
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The first line contains an integer $t$ ( $1 \le t \le 100$ ) — the number of test cases. Then follows the description of each test case.
The first line of each test case contains three natural numbers $n$ , $m$ , and $k$ ( $1 \le n, m \le 100, 1 \le k \le 2000$ ) — the number of coins in the left and right pockets, and the maximum sum of two coins for the ticket payment at the counter, respectively.
The second line of each test case contains $n$ integers $b_i$ ( $1 \le b_i \le 1000$ ) — the denominations of coins in the left pocket.
The third line of each test case contains $m$ integers $c_i$ ( $1 \le c_i \le 1000$ ) — the denominations of coins in the right pocket.
The first line of each test case contains three natural numbers $n$ , $m$ , and $k$ ( $1 \le n, m \le 100, 1 \le k \le 2000$ ) — the number of coins in the left and right pockets, and the maximum sum of two coins for the ticket payment at the counter, respectively.
The second line of each test case contains $n$ integers $b_i$ ( $1 \le b_i \le 1000$ ) — the denominations of coins in the left pocket.
The third line of each test case contains $m$ integers $c_i$ ( $1 \le c_i \le 1000$ ) — the denominations of coins in the right pocket.
输入格式
For each testcase, output a single integer — the number of ways Rudolf can select two coins, taking one from each pocket, so that the sum of the coins does not exceed $k$ .
输出格式
Note that the pairs indicate the indices of the coins in the array, not their denominations.
In the first test case, Rudolf can choose the following pairs of coins: $[1, 1], [1, 2], [1, 4], [2, 1], [2, 2], [2, 4]$ .
In the second test case, Rudolf cannot choose one coin from each pocket in any way, as the sum of any two elements from the first and second arrays will exceed the value of $k=4$ .
In the third test case, Rudolf can choose: $[1, 1], [2, 1], [3, 1], [4, 1]$ .
In the fourth test case, Rudolf can choose any coin from the left pocket and any coin from the right pocket.
In the first test case, Rudolf can choose the following pairs of coins: $[1, 1], [1, 2], [1, 4], [2, 1], [2, 2], [2, 4]$ .
In the second test case, Rudolf cannot choose one coin from each pocket in any way, as the sum of any two elements from the first and second arrays will exceed the value of $k=4$ .
In the third test case, Rudolf can choose: $[1, 1], [2, 1], [3, 1], [4, 1]$ .
In the fourth test case, Rudolf can choose any coin from the left pocket and any coin from the right pocket.
输入输出样例
输入 #1
4 4 4 8 1 5 10 14 2 1 8 1 2 3 4 4 8 1 2 3 4 2 7 1 1 1 1 2 7 3 4 2000 1 1 1 1 1 1 1
输出 #1
6 0 4 12
Note that the pairs indicate the indices of the coins in the array, not their denominations.
In the first test case, Rudolf can choose the following pairs of coins: $[1, 1], [1, 2], [1, 4], [2, 1], [2, 2], [2, 4]$ .
In the second test case, Rudolf cannot choose one coin from each pocket in any way, as the sum of any two elements from the first and second arrays will exceed the value of $k=4$ .
In the third test case, Rudolf can choose: $[1, 1], [2, 1], [3, 1], [4, 1]$ .
In the fourth test case, Rudolf can choose any coin from the left pocket and any coin from the right pocket.
In the first test case, Rudolf can choose the following pairs of coins: $[1, 1], [1, 2], [1, 4], [2, 1], [2, 2], [2, 4]$ .
In the second test case, Rudolf cannot choose one coin from each pocket in any way, as the sum of any two elements from the first and second arrays will exceed the value of $k=4$ .
In the third test case, Rudolf can choose: $[1, 1], [2, 1], [3, 1], [4, 1]$ .
In the fourth test case, Rudolf can choose any coin from the left pocket and any coin from the right pocket.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted