1 条题解
-
0
洛谷传送门:https://www.luogu.com.cn/problem/P4670
LOJ 传送门:https://loj.ac/p/2635
博客传送门:https://oi-master.gitee.io/2020/12/22/BalticOI-2011-Day2-Plagiarism-题解/
这题绝对是道水题。跟我一样用
STL的同学,请喊:STL!STL!STL 强!
我们发现 只有 大,意味着我们可以使用 的方法解决此题。
首先,我们先排序此数列。可以使用
STL的sort()函数排序。然后,我们发现对于每个数,需要对比的程序在排过序的数列中有单调性:当 不用比较时,那么 也不用比较。
那么可以算出每个数字 是多少,然后用
STL的lower_bound()函数二分。所以需要您手写的除了输入输出就没什么了。
#include<iostream> #include<algorithm> #include<cmath> using namespace std; #define int long long signed main(){ int n; cin>>n; int a[n+1]; for(int i=1;i<=n;++i) cin>>a[i]; sort(a+1,a+n+1); int sum=0; for(int i=1;i<=n;++i){ int now=ceil(a[i]*90.0/100); int j=lower_bound(a+1,a+i,now)-a; sum+=i-j; } cout<<sum<<endl; }
- 1
信息
- ID
- 10553
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者