题目链接:https://nanti.jisuanke.com/t/28879

思路:贪心,从最早收到请求的时刻开始,统计每个相差1000毫秒的时间段内接收的请求数量再计算该时间段内所需机器数目,答案就是所有时间段中最大的机器数目

 #include<iostream>
#define inf 0x3f3f3f3f
using namespace std;
int a[];
int main()
{
int n,k,maxx=,minn=inf;
cin>>n>>k;
for(int i=;i<;i++)
a[i]=;
for(int i=;i<n;i++)
{
int t;
cin>>t;
maxx=max(t,maxx);
minn=min(t,minn);
a[t]++;
}
int ans=,cnt,num;
for(int i=minn;i<=maxx;i+=)
{
cnt=,num=;
for(int j=;j<;j++)
if(a[i+j])
num+=a[i+j];
if(num<=k)cnt=;
else
{
cnt=num/k;
if(num%k)cnt++;
}
ans=max(ans,cnt);
}
cout<<ans<<endl;
return ;
}

CSU 1684-Disastrous Downtime的更多相关文章

  1. Nordic Collegiate Programming Contest 2015​ D. Disastrous Downtime

    You're investigating what happened when one of your computer systems recently broke down. So far you ...

  2. NCPC 2015 October 10, 2015 Problem D

    NCPC 2015Problem DDisastrous DowntimeProblem ID: downtimeClaus Rebler, cc-by-saYou’re investigating ...

  3. Nordic Collegiate Programming Contest 2015​(第七场)

    A:Adjoin the Networks One day your boss explains to you that he has a bunch of computer networks tha ...

  4. csu 1812: 三角形和矩形 凸包

    传送门:csu 1812: 三角形和矩形 思路:首先,求出三角形的在矩形区域的顶点,矩形在三角形区域的顶点.然后求出所有的交点.这些点构成一个凸包,求凸包面积就OK了. /************** ...

  5. CSU 1503 点到圆弧的距离(2014湖南省程序设计竞赛A题)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1503 解题报告:分两种情况就可以了,第一种是那个点跟圆心的连线在那段扇形的圆弧范围内,这 ...

  6. CSU 1120 病毒(DP)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1120 解题报告:dp,用一个串去更新另一个串,递推方程是: if(b[i] > a ...

  7. CSU 1116 Kingdoms(枚举最小生成树)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1116 解题报告:一个国家有n个城市,有m条路可以修,修每条路要一定的金币,现在这个国家只 ...

  8. CSU 1113 Updating a Dictionary(map容器应用)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 解题报告:输入两个字符串,第一个是原来的字典,第二个是新字典,字典中的元素的格式为 ...

  9. CSU 1333 Funny Car Racing (最短路)

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1333 解题报告:一个图里面有n个点和m条单向边,注意是单向边,然后每条路开a秒关闭b秒 ...

随机推荐

  1. ionic3安卓版release发布

    1.进入到项目根目录 keytool -genkey -v -keystore your-full-keystore-name.keystore -alias your-lias-name -keya ...

  2. 用网站把图标做成iconFont文件引用

    1,把psd文件另存为eps文件(ai能打开的格式),前提图标有路径, 2,用ai打开eps文件 3,新建一个空白文件100*100,然后把图标复制进来,等比拉宽至最大化 4,如果图标有蒙版,就点击图 ...

  3. Hibernate多对一ManytoOne

    ------------------------Hibernate多对一ManytoOne 要点: ManytoOne配置在多端 可以配置级联操作 @ManyToOne(cascade=Cascade ...

  4. Spark+Scalar+Mysql

    包:mysql-connector-java-5.1.39-bin.jar 平台:Win8.1 环境:MyEclipse2015 hadoop-2.7.3.tar.gz + winutils.exe ...

  5. How to identify safari in Mac?

    How to identify safari in Mac?in userAgent, find keywords below1) and: Macintosh, Mac OS X, AppleWeb ...

  6. Python直接改变实例化对象的列表属性的值 导致在flask中接口多次请求报错

    错误原理实例如下: class One(): list = [1, 2, 3] @classmethod def get_copy_list(cls): # copy一份list,这样对list的改变 ...

  7. leetcode312

    class Solution { public int maxCoins(int[] iNums) { int[] nums = new int[iNums.length + 2]; int n = ...

  8. tensorflow实战讨论

    欢迎关注微信公众号:樱园的玻尔兹曼机

  9. Python入门:Anaconda和Pycharm的安装和配置

    Python入门:Anaconda和Pycharm的安装和配置  转自:https://www.cnblogs.com/yuxuefeng/articles/9235431.html 子曰:“工欲善其 ...

  10. Linux网络编程学习(六) ----- 管道(第四章)

    1.管道的定义 管道就是将一个程序的输出和另外一个程序的输入连接起来的单向通道,比如命令: ls -l|more,就建立了一个管道,获取ls -l的输出作为more的输入,数据就沿着管道从管道的左边流 ...