A6518 | 「BalticOI 2011 Day2」剽窃 Plagiarism
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
** 译自 BalticOI 2011 Day2 T2「Plagiarism」**
有 $N$ 个数 $f_1, f_2, \ldots, f_N$,试求:有多少对 $(f_i, f_j)\,\,(1\le i<j\le N)$ 满足 $(0.9×f_j)\le f_i\le f_j$。
The participants of the World Programming Competition submitted $N$ solution files $f_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 $(f_i, f_j)$ where $i≠j$, $\textrm{size}(f_i) ≤ \textrm{size}(f_j)$ and $\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.
有 $N$ 个数 $f_1, f_2, \ldots, f_N$,试求:有多少对 $(f_i, f_j)\,\,(1\le i<j\le N)$ 满足 $(0.9×f_j)\le f_i\le f_j$。
The participants of the World Programming Competition submitted $N$ solution files $f_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 $(f_i, f_j)$ where $i≠j$, $\textrm{size}(f_i) ≤ \textrm{size}(f_j)$ and $\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.
输入格式
第一行有一个整数 $N$。
第二行有 $N$ 个整数 $f_1, f_2, \ldots, f_N$。
The first line of input contains the integer $N$, the number of solution files submitted. The second line contains $N$ integers $\textrm{size}(f_1),...,\textrm{size}(f_N)$, each showing the size of one file.
第二行有 $N$ 个整数 $f_1, f_2, \ldots, f_N$。
The first line of input contains the integer $N$, the number of solution files submitted. The second line contains $N$ integers $\textrm{size}(f_1),...,\textrm{size}(f_N)$, each showing the size of one file.
输出格式
一行一个整数,表示有多少对 $(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.
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
输出 #1
0
输入 #2
5 1 1 1 1 1
输出 #2
10
对于 $50\%$ 的数据,$ 1 ≤ N ≤ 2000$。
对于所有数据,$ 1 ≤ N ≤ 10^5, 1 ≤ f_i ≤ 10^8 $。
对于所有数据,$ 1 ≤ N ≤ 10^5, 1 ≤ f_i ≤ 10^8 $。
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?