CF1324D.Pair of Topics

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The next lecture in a high school requires two topics to be discussed. The ii-th topic is interesting by aia_i units for the teacher and by bib_i units for the students.

The pair of topics ii and jj (i<ji \lt j) is called good if ai+aj>bi+bja_i + a_j \gt b_i + b_j (i.e. it is more interesting for the teacher).

Your task is to find the number of good pairs of topics.

高中下一节课需要讨论两个主题。第 ii 个主题对教师的吸引力为 aia_i 单位,对学生吸引力为 bib_i 单位。

若一对主题 ii 和 jj(其中 i<ji \lt j)满足 ai+aj>bi+bja_i + a_j \gt b_i + b_j(即对教师而言整体更有趣),则称其为好对。

你的任务是求出好对的数量。

输入格式

The first line of the input contains one integer nn (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5) — the number of topics.

The second line of the input contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \le a_i \le 10^9), where aia_i is the interestingness of the ii-th topic for the teacher.

The third line of the input contains nn integers b1,b2,…,bnb_1, b_2, \dots, b_n (1≤bi≤1091 \le b_i \le 10^9), where bib_i is the interestingness of the ii-th topic for the students.

输入的第一行包含一个整数 nn(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5)—— 表示主题的数量。

输入的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1091 \le a_i \le 10^9),其中 aia_i 表示第 ii 个主题对教师的有趣程度。

输入的第三行包含 nn 个整数 b1,b2,…,bnb_1, b_2, \dots, b_n(1≤bi≤1091 \le b_i \le 10^9),其中 bib_i 表示第 ii 个主题对学生的有趣程度。

输出格式

Print one integer — the number of good pairs of topic.

输出一个整数——主题的好配对数量。

输入输出样例

  • 输入#1

    5
    4 8 2 6 2
    4 5 4 1 3

    输出#1

    7
  • 输入#2

    4
    1 3 2 4
    1 3 2 4

    输出#2

    0

输入解题思路,AI测评打分。不知道怎么写?

首页