#TP0000048. Cặp chủ đề thú vị (Pair of Topics)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cặp chủ đề thú vị (Pair of Topics)
Pair of Topics
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A school lecture requires two topics to be discussed. There are topics, numbered from to . For topic , the teacher assigns an interestingness value , while the students assign a value .
For two distinct topics , the teacher's combined interestingness is , and the students' combined interestingness is .
A pair is good if the teacher's total is strictly greater than the students' total:
Count all good pairs of topics. Different index pairs count separately, even when the associated values are equal.
Input
- The first line contains the integer , the number of topics.
- The second line contains exactly integers , giving the teacher's values.
- The third line contains exactly integers , giving the students' values for the corresponding topics.
Output
Print one integer: the number of index pairs with and .
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
5
4 8 2 6 2
4 5 4 1 3
Output
7
Explanation
Subtracting the students' values from the teacher's values gives . A pair is good precisely when its two differences sum to a positive number. The seven valid pairs are , , , , , , and . The other three pairs have a non-positive difference sum, so the output is 7.