codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1324D.md (1203B)


      1 Source: https://codeforces.com/problemset/problem/1324/D
      2 
      3 D. Pair of Topics
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 The next lecture in a high school requires two topics to be discussed. The $i$-th topic is interesting by $a_i$ units for the teacher and by $b_i$ units for the students.
     22 
     23 The pair of topics $i$ and $j$ ($i \lt j$) is called good if $a_i + a_j \gt b_i + b_j$ (i.e. it is more interesting for the teacher).
     24 
     25 Your task is to find the number of good pairs of topics.
     26 
     27 Input
     28 
     29 The first line of the input contains one integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the number of topics.
     30 
     31 The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is the interestingness of the $i$-th topic for the teacher.
     32 
     33 The third line of the input contains $n$ integers $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$), where $b_i$ is the interestingness of the $i$-th topic for the students.
     34 
     35 Output
     36 
     37 Print one integer — the number of good pairs of topic.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 5
     45 4 8 2 6 2
     46 4 5 4 1 3
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 7
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 4
     59 1 3 2 4
     60 1 3 2 4
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 0
     67 ```