102315: [AtCoder]ABC231 F - Jealous Two

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $500$ points

Problem Statement

Snuke is planning on giving one gift each to Takahashi and Aoki.
There are $N$ candidates for the gifts. Takahashi's impression of the $i$-th candidate is $A_i$, and Aoki's impression of it is $B_i$.

The two are very jealous. If Takahashi's impression of the gift Aoki gets is greater than Takahashi's impression of the gift Takahashi gets, Takahashi gets jealous of Aoki and starts fighting, and vice versa.

Among the $N^2$ possible ways of giving the gifts, how many do not lead to fighting?

Constraints

  • $1 \leq N \leq 2\times 10^5$
  • $0 \leq A_i \leq 10^9$
  • $0 \leq B_i \leq 10^9$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$
$A_1$ $\ldots$ $A_N$
$B_1$ $\ldots$ $B_N$

Output

Print the answer.


Sample Input 1

3
50 100 150
1 3 2

Sample Output 1

4

For example, if we give the $1$-st candidate to Takahashi and the $2$-nd candidate to Aoki, Takahashi's impression of the gift Aoki gets is $100$, while Takahashi's impression of the gift Takahashi gets is $50$, so Takahashi gets jealous of Aoki and starts fighting.

As another example, if we give the $3$-rd candidate to Takahashi and the $2$-nd candidate to Aoki, the two will not start fighting.

Note that it is allowed to give the same gift to the two.


Sample Input 2

3
123456789 123456 123
987 987654 987654321

Sample Output 2

6

Sample Input 3

10
3 1 4 1 5 9 2 6 5 3
2 7 1 8 2 8 1 8 2 8

Sample Output 3

37

Input

题意翻译

## 题目描述  滑头君要给他的两个好基友 A、B 每人送一个礼物。\  滑头君有 **$ N $ 种**礼物,对于每种礼物,两个好基友都有不同的喜爱值。\  两个好基友非常嫉妒。对于任意一个人来说,如果对方收到的礼物对自己的喜爱值比自己的礼物对自己的喜爱值更高,换句话说就是如果有人更喜欢对方的礼物的话,两个人就会打架。\  滑头君不想失去他的朋友,于是请你求出共有几种可能的送礼方案。 **请注意,可以给两个人送同样的礼物。** ## 输入格式 >第一行一个整数 $ N $ 第二行 $ N $ 个整数$ A_1 $ $ \ldots $ $ A_N $ 表示 A 对第 $i$个礼物的喜欢值。 第三行 $ N $ 个整数$ B_1 $ $ \ldots $ $ B_N $ 表示 B 对第 $i$个礼物的喜欢值。 ## 输出格式 输出可能的方案数。

Output

分数:500分

问题描述

Snuke计划分别给Takahashi和Aoki送一份礼物。

有N个礼物候选。Takahashi对第i个候选礼物的印象是Ai,Aoki对它的印象是Bi。

两人非常嫉妒。如果Takahashi对Aoki得到的礼物的印象大于Takahashi对Takahashi得到的礼物的印象,Takahashi就会嫉妒Aoki并开始打架,反之亦然。

在N2种可能的送礼方式中,有多少种不会导致打架?

约束条件

  • $1 \leq N \leq 2\times 10^5$
  • $0 \leq A_i \leq 10^9$
  • $0 \leq B_i \leq 10^9$
  • 输入中的所有值都是整数。

输入

从标准输入按以下格式获取输入:

$N$
$A_1$ $\ldots$ $A_N$
$B_1$ $\ldots$ $B_N$

输出

打印答案。


样例输入1

3
50 100 150
1 3 2

样例输出1

4

例如,如果我们把第1个候选礼物给Takahashi,第2个候选礼物给Aoki,Takahashi对Aoki得到的礼物的印象是100, 而Takahashi对Takahashi得到的礼物的印象是50, 所以Takahashi会嫉妒Aoki并开始打架。

作为另一个例子,如果我们把第3个候选礼物给Takahashi,第2个候选礼物给Aoki,两人就不会开始打架。

请注意,允许将相同的礼物送给两人。


样例输入2

3
123456789 123456 123
987 987654 987654321

样例输出2

6

样例输入3

10
3 1 4 1 5 9 2 6 5 3
2 7 1 8 2 8 1 8 2 8

样例输出3

37

加入题单

算法标签: