#P50743. 「BalticOI 2011 Day2」剽窃 Plagiarism

「BalticOI 2011 Day2」剽窃 Plagiarism

题目描述

** 译自 BalticOI 2011 Day2 T2「Plagiarism」**

NN 个数 f1,f2,,fNf_1, f_2, \ldots, f_N,试求:有多少对 (fi,fj)(1i<jN)(f_i, f_j)\,\,(1\le i<j\le N) 满足 (0.9×fj)fifj(0.9×f_j)\le f_i\le f_j

The participants of the World Programming Competition submitted NN solution files f1,...,fNf_1 ,...,f_N to the grading system. Before accepting the results as final, the jury would like to rule out any possibility of plagiarism. They have a program that takes two files and compares them to decide if they are too similar to each other.
However, the number of files is rather big and it would take too much time to compare all pairs. On the other hand, many pairs could be quickly eliminated based on the fact that the file sizes are too different.
More precisely, the jury decided to fully skip comparing every pair where the size of the smaller file is less than 90% of the size of the larger one. So, the comparison program has to examine only those distinct pairs of files (fi,fj)(f_i, f_j) where iji≠j, size(fi)size(fj)\textrm{size}(f_i) ≤ \textrm{size}(f_j) and size(fi)0.9×size(fj)\textrm{size}(f_i ) ≥ 0.9 \times \textrm{size}(f_j).
Write a program that computes the number of pairs of files that will have to be examined.

输入格式

第一行有一个整数 NN
第二行有 NN 个整数 f1,f2,,fNf_1, f_2, \ldots, f_N

The first line of input contains the integer NN, the number of solution files submitted. The second line contains NN integers size(f1),...,size(fN)\textrm{size}(f_1),...,\textrm{size}(f_N), each showing the size of one file.

输出格式

一行一个整数,表示有多少对 (fi,fj)(1fi<fjN)(f_i, f_j)\,\,(1\le f_i<f_j\le N) 满足条件。

The first and only line of output must contain one integer, the number of pairs of files that will have to be examined.

样例 1

2
2 1
0
5
1 1 1 1 1
10

数据范围与提示

对于 50%50\% 的数据,1N2000 1 ≤ N ≤ 2000
对于所有数据,1N105,1fi108 1 ≤ N ≤ 10^5, 1 ≤ f_i ≤ 10^8