QOJ.ac

QOJ

시간 제한: 2.0 s 메모리 제한: 512 MB 총점: 100

#14792. 渡轮

통계

Johnny 正在为毕业舞会做准备,舞会传统上以波洛奈兹舞(polonnaise dance)开场。任何男女混合对(男生和女生)都可以领舞,只要他们的身高相差不太大。更具体地说,他们的身高差不能超过 $k$ 字节米(byteometers)。Jimmy 想知道有多少种选择领舞对的方法。

编写一个程序,读取所有女生和男生的身高,计算可能的领舞对数量,并将结果输出。

输入格式

第一行包含三个空格分隔的整数 $n$、$m$ 和 $k$($1 \le n, m \le 250\,000$,$0 \le k \le 1\,000\,000\,000$),分别表示女生人数、男生人数以及领舞对的最大可能身高差。

第二行包含一个由 $n$ 个空格分隔的整数组成的序列 $a_i$($1 \le a_i \le 1\,000\,000\,000$),表示女生的身高(单位:字节米)。

第三行包含一个由 $m$ 个空格分隔的整数组成的序列 $b_i$($1 \le b_i \le 1\,000\,000\,000$),表示男生的身高(单位:字节米)。

输出格式

输出第一行且仅包含一个整数,表示可能的领舞对数量。

样例

输入样例 1

4 5 5
15 2 5 7
1 5 10 15 1

输出样例 1

11

说明

共有 11 种可能的领舞对:$(15, 10)$、$(15, 15)$、$(2, 1)$、$(2, 5)$、$(2, 1)$、$(5, 1)$、$(5, 5)$、$(5, 10)$、$(5, 1)$、$(7, 5)$ 和 $(7, 10)$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.