Baltic OI '11 P6 - Plagiarism

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type
Baltic Olympiad in Informatics: 2011 Day 2, Problem 2

The participants of the World Programming Competition submitted N solution files f_1, \dots, 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 (f_i, f_j) where i \ne j, \text{size}(f_i) \le \text{size}(f_j) and \text{size}(f_i) \ge 0.9 \cdot \text{size}(f_j).

Write a program that computes the number of pairs of files that will have to be examined.

Constraints

1 \le N \le 10^5

1 \le \text{size}(f_i) \le 10^8

Subtask 1 [50%]

1 \le N \le 2\,000

Subtask 2 [50%]

No additional constraints.

Input Specification

The first line of input contains the integer N, the number of solution files submitted. The second line contains N space-separated integers: \text{size}(f_1), \dots, \text{size}(f_N), each showing the size of one file.

Output Specification

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

Sample Input 1

2
2 1

Sample Output 1

0

Sample Input 2

5
1 1 1 1 1

Sample Output 2

10

Explanation for Sample 2

Each file has to be compared to each other (but each pair only once, not twice, of course).


Comments

There are no comments at the moment.