bzoj2013
来源:互联网 发布:查询域名注册信息 编辑:程序博客网 时间:2024/05/22 12:34
按照长度排序
考虑对于前i-1的元素的排列,第i个元素可以插入的合法位置为x
在排好序的序列中二分找可以插入的位置满足a[i]<=a[k]+D
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#define maxn 620005#define mod 1000000009#define LL long longusing namespace std;int n,D;LL ans;int a[maxn];int main(){ scanf("%d%d",&n,&D); for(int i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+n+1); ans=1; int t; for(int i=2;i<=n;i++){ t=lower_bound(a+1,a+i+1,a[i]-D)-a; t=(i-t+1); ans=(ans*1ll*t)%mod; } printf("%lld\n",ans%mod); return 0;}
阅读全文
0 0
- bzoj2013
- 【CEOI2010】【BZOJ2013】A huge tower
- 【bzoj2013】[Ceoi2010]A huge tower
- bzoj2013 [Ceoi2010]A huge tower
- BZOJ2013 [Ceoi2010]A huge tower 乱搞
- PL/SQL的基本语法结构和案例演示
- 二分图最大匹配(匈牙利算法)整理
- JZOJ 5419. 【NOIP2017提高A组集训10.24】筹备计划
- MATLAB教程(1) MATLAB 基础知识
- 数组的特点,数组的使用,链表的特点,set和list的区别,arrayList,linkedList,的常用方法,set,hashset,
- bzoj2013
- Data Stream Median
- 47. Permutations II
- 解决Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!
- 监控中心方案设计
- python __slot__
- P
- Spark SQL 个人总结
- C++进阶—>互斥量:Event控制:多线程实现生产者-消费者例子