P是端点,牛在区域中啊。。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std;
const int N=1005;
int pt[N],s[N];
int n,p,c; int slove(int st){
int ans=0;
int l=st,r=p-1,m;
while(l<=r){
m=(l+r)/2;
if(s[m]-s[st-1]<=c){
ans=(m-st+1);
l=m+1;
}
else r=m-1;
}
return ans;
} int main(){
int tmp;
while(scanf("%d%d%d",&n,&p,&c)!=EOF){
memset(pt,0,sizeof(pt));
for(int i=1;i<=n;i++){
scanf("%d",&tmp);
pt[tmp]++;
}
s[0]=0;
for(int i=1;i<p;i++){
s[i]=s[i-1]+pt[i];
}
int ans=0;
for(int i=1;i<p;i++){
ans=max(ans,slove(i));
}
printf("%d\n",ans);
}
return 0;
}

  

POJ 2189的更多相关文章

  1. POJ 2189 枚举

    题意: n头牛,p长度的道路,问至多包括c头牛的道路最长有多长. 思路: 按照题意暴力就好-- 注意边界. // by SiriusRen #include <cstdio> #inclu ...

  2. poj 题目分类(1)

    poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...

  3. POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)

    本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...

  4. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  5. 转载:poj题目分类(侵删)

    转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码)  ...

  6. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  7. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  8. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  9. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

随机推荐

  1. modelstate.isvalid false

    http://stackoverflow.com/questions/1791570/modelstate-isvalid-false-why 第一个 About "can it be th ...

  2. TensorRT加速 ——NVIDIA终端AI芯片加速用,可以直接利用caffe或TensorFlow生成的模型来predict(inference)

    官网:https://developer.nvidia.com/tensorrt 作用:NVIDIA TensorRT™ is a high-performance deep learning inf ...

  3. EOJ 3348 树的顺序存储结构

    前面介绍了树的链式存储结构,那么如何用顺序存储来存储一棵树呢?在顺序存储时,我们除了存储每个结点值外,还要存储树中结点与结点之间的逻辑关系(即双亲与孩子结点之间的关系).下面介绍树的双亲存储法. 编号 ...

  4. TreeSet中的排序问题——Comparable

    package com.etc.hashset; import java.util.HashSet; import java.util.Iterator; import java.util.Set; ...

  5. Hadoop MapReduce编程 API入门系列之倒排索引(二十四)

    不多说,直接上代码. 2016-12-12 21:54:04,509 INFO [org.apache.hadoop.metrics.jvm.JvmMetrics] - Initializing JV ...

  6. Hadoop MapReduce编程 API入门系列之自定义多种输入格式数据类型和排序多种输出格式(十一)

    推荐 MapReduce分析明星微博数据 http://git.oschina.net/ljc520313/codeexample/tree/master/bigdata/hadoop/mapredu ...

  7. 大数据查询——HBase读写设计与实践--转

    背景介绍 本项目主要解决 check 和 opinion2 张历史数据表(历史数据是指当业务发生过程中的完整中间流程和结果数据)的在线查询.原实现基于 Oracle 提供存储查询服务,随着数据量的不断 ...

  8. Aspose.cell中的Excel模板导出数据

    //Excel模板导数据(Eexcel中根据DataTable中的个数,给多个Sheet中的模板赋值) public void DataSetToManyExcel(string fileName, ...

  9. The name ‘InitialzeComponent’ does not exist in the current context

    在Visual Studio中创建Windows Store项目,在MainPage.xaml.cs中出现错误: The name 'InitialzeComponent' does not exis ...

  10. tomcat 启动服务器日志小结

    1.tomcat 启动服务配置: 目前主要有  ①把编译好war或者项目直接扔到webapps 目录下, 启动bin目录下的startup.bat 即可   ②  在conf目录下 修改  serve ...