题目链接: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. Hash 1.04 右键

    http://keir.net/hash.html Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Hash 1.04\ ...

  2. vagrant The specified host network collides with a non-hostonly network!

    换个ip scripts\homestead.rb config.vm.network :private_network, ip: settings["ip"] ||= " ...

  3. Verilog HDL中的运算符关系

    1,位运算符 按位运算的运算符是位运算符,原来的操作数有几位,结果就有几位,若两个操作数位数不同,则位数短的操作数左端会自动补0. (1),按位取反:~ (2),按位与:& (3),按位或:| ...

  4. json 数据在textarea中显示的时候,切换 beauty和ugly模式

    转化为beauty模式 var jsonText = $('#json').val(); $('#json').val(JSON.stringify(JSON.parse(jsonText), nul ...

  5. vld for memory leak detector (release version)

    有没有这样的情况,无法静态的通过启动和退出来查找内存泄露,比如网络游戏,你总不能直接关游戏那玩家怎么办? 现在vld支持release,我们可以动态的找. 1.在release版本使用vld了.< ...

  6. 用EXCEL做快速傅立葉轉換_FFT in Excel

    转载来自:http://yufan-fansbook.blogspot.tw/2013/09/excel-fft-fast-fourier-transform02.html [Excel]-用EXCE ...

  7. Java 身份证号码验证

    身份证号码验证 1.号码的结构 公民身份号码是特征组合码,由十七位数字本体码和一位校验码组成.排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码 2.地址码(前 ...

  8. 调整iframe滚动条失效

    1:<iframe scrolling="auto" frameborder="0" src="' + add + '" style= ...

  9. 工作流调度器azkaban

    为什么需要工作流调度系统 一个完整的数据分析系统通常都是由大量任务单元组成: shell脚本程序,java程序,mapreduce程序.hive脚本等 各任务单元之间存在时间先后及前后依赖关系 为了很 ...

  10. ElasicSearch(4) 与jest结合

    https://spring.io/projects/spring-data-elasticsearch https://docs.spring.io/spring-data/elasticsearc ...