CF1941A.Rudolf and the Ticket

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The first line contains an integer tt ( 1t1001 \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 nn , mm , and kk ( 1n,m100,1k20001 \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 nn integers bib_i ( 1bi10001 \le b_i \le 1000 ) — the denominations of coins in the left pocket.

The third line of each test case contains mm integers cic_i ( 1ci10001 \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 kk .

输出格式

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][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=4k=4 .

In the third test case, Rudolf can choose: [1,1],[2,1],[3,1],[4,1][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][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=4k=4 .

In the third test case, Rudolf can choose: [1,1],[2,1],[3,1],[4,1][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.

首页