CF1941A.Rudolf and the Ticket
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Rudolf is going to visit Bernard, and he decided to take the metro to get to him. The ticket can be purchased at a machine that accepts exactly two coins, the sum of which does not exceed k.
Rudolf has two pockets with coins. In the left pocket, there are n coins with denominations b1,b2,…,bn. In the right pocket, there are m coins with denominations c1,c2,…,cm. He wants to choose exactly one coin from the left pocket and exactly one coin from the right pocket (two coins in total).
Help Rudolf determine how many ways there are to select indices f and s such that bf+cs≤k.
鲁道夫将去拜访伯纳德,他决定乘坐地铁前往。车票可以在一台自动售票机上购买,该机器恰好接受两枚硬币,且这两枚硬币的面值之和不超过 k。
鲁道夫有两个装有硬币的口袋。左口袋中有 n 枚硬币,面值分别为 b1,b2,…,bn;右口袋中有 m 枚硬币,面值分别为 c1,c2,…,cm。他希望从左口袋中恰好选一枚硬币,同时从右口袋中也恰好选一枚硬币(总共两枚硬币)。
请帮助鲁道夫计算:有多少种方式选择下标 f 和 s,使得 bf+cs≤k。
输入格式
The first line contains an integer t (1≤t≤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≤n,m≤100,1≤k≤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 bi (1≤bi≤1000) — the denominations of coins in the left pocket.
The third line of each test case contains m integers ci (1≤ci≤1000) — the denominations of coins in the right pocket.
第一行包含一个整数 t(1≤t≤100),表示测试用例的数量。随后是每个测试用例的描述。
每个测试用例的第一行包含三个正整数 n、m 和 k(1≤n,m≤100,1≤k≤2000),分别表示左口袋和右口袋中的硬币数量,以及在柜台购买车票时两枚硬币面值之和的最大允许值。
每个测试用例的第二行包含 n 个整数 bi(1≤bi≤1000),表示左口袋中各硬币的面值。
每个测试用例的第三行包含 m 个整数 ci(1≤ci≤1000),表示右口袋中各硬币的面值。
输出格式
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.
对于每个测试用例,输出一个整数——鲁道夫从两个口袋中各选一枚硬币,使得这两枚硬币面值之和不超过 k 的方案数。
输入输出样例
输入#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.
注意:这些数对表示数组中硬币的索引,而非其面值。
在第一个测试用例中,Rudolf 可以选择以下硬币对:[1,1],[1,2],[1,4],[2,1],[2,2],[2,4]。
在第二个测试用例中,Rudolf 无法以任何方式从每个口袋中各选一枚硬币,因为第一个数组与第二个数组中任意两个元素之和均会超过 k=4。
在第三个测试用例中,Rudolf 可以选择:[1,1],[2,1],[3,1],[4,1]。
在第四个测试用例中,Rudolf 可以从左口袋中任选一枚硬币,并从右口袋中任选一枚硬币。
输入解题思路,AI测评打分。不知道怎么写?