You’re investigating what happened when one of your computer systems recently broke down. So far you’ve concluded that the system was overloaded; it looks like it couldn’t handle the hailstorm of incoming requests. Since the incident, you have had ample opportunity to add more servers to your system, which would make it capable of handling more concurrent requests. However, you’ve simply been too lazy to do it—until now. Indeed, you shall add all the necessary servers . . . very soon!

To predict future requests to your system, you’ve reached out to the customers of your service, asking them for details on how they will use it in the near future. The response has been pretty impressive; your customers have sent you a list of the exact timestamp of every request they will ever make!

You have produced a list of all the n upcoming requests specified in milliseconds. Whenever a request comes in, it will immediately be sent to one of your servers. A request will take exactly 1000 milliseconds to process, and it must be processed right away.

Each server can work on at most k requests simultaneously. Given this limitation, can you calculate the minimum number of servers needed to prevent another system breakdown?

Input

The first line contains two integers 1 ≤ n ≤ 100 000 and 1 ≤ k ≤ 100 000, the number of upcoming requests and the maximum number of requests per second that each server can handle. Then follow n lines with one integer 0 ≤ ti ≤ 100 000 each, specifying that the ith request will happen ti milliseconds from the exact moment you notified your customers. The timestamps are sorted in chronological order. It is possible that several requests come in at the same time.

Output

Output a single integer on a single line: the minimum number of servers required to process all the incoming requests, without another system breakdown.

Sample Input 1

2 1

0

1000

Sample Output 1

1

Sample Input 2

3 2

1000

1010

1999

Sample Output 2

2

组队赛的一道题目题意很简单,当时想着用STL什么的做的,HRX小姐姐说有思路就去敲了,很快AC,看了她的代码,思路很巧妙,平常的思路都是按照时间的进行,去看看电脑,考虑电脑,小姐姐的思路是看1s的时间里最多要用到几台电脑,非常神奇,或许这就是大佬吧,贴下代码

#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <stack>
#include <map>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
const int maxn = 100 + 10;
int t[maxn];
int main()
{int n,k,x,ans = 0;memset(t,0,sizeof(t));scanf("%d%d",&n,&k);for(int i=1;i<=n;i++){scanf("%d",&x);t[x/1000]++;if(t[x/1000] % k == 0) ans = max(ans,t[x/1000] / k);else ans = max(ans,t[x/1000] / k + 1);}printf("%d\n",ans);return 0;
}

Disastrous Downtime相关推荐

  1. True Zero Downtime HAProxy Reloads--转载

    原文地址:http://engineeringblog.yelp.com/2015/04/true-zero-downtime-haproxy-reloads.html HAProxy: Corner ...

  2. Recompile/upgrade nginx binary with no down-time

    网址:http://www.softwareprojects.com/resources/programming/t-recompileupgrade-nginx-binary-with-no-dow ...

  3. D - Disastrous Doubling Kattis - disastrousdoubling

    D - Disastrous Doubling 题意:1个细菌一小时分裂一次,每次分裂后都会做实验取走一部分细菌,问最后剩多少细菌(mod 1e9+7). 思路:ans = (ans*2%mod-a[ ...

  4. 用阿里云托管服务器怎么托管_云托管就像圣诞老人的4种方式

    用阿里云托管服务器怎么托管 You might think it Christmas crackers to believe a beardy, old sleigh driver donning a ...

  5. 托管 非托管_选择托管服务提供商的终极指南

    托管 非托管 This article is part of a series created in partnership with SiteGround. Thank you for suppor ...

  6. 《97 Things Every Software Architect Should Know》读书笔记

    (从网上搜集的,并且整理为DOC文档,希望大家可以从这篇文章中学到更多的东西, 我准备将该文档翻译成中文,大家可以不定期的访问我的博客http://blog.csdn.net/jianglike18) ...

  7. java uiautomation_Java UiAutomation類代碼示例

    本文整理匯總了Java中android.app.UiAutomation類的典型用法代碼示例.如果您正苦於以下問題:Java UiAutomation類的具體用法?Java UiAutomation怎 ...

  8. Nagios监控笔记上

    Nagios软件介绍及服务端安装部署实战 1. Nagios服务端安装 1.1 准备3台服务器或者虚拟机器 管理IP地址 角色 备注 192.168.1.80 Nagios监控服务器 192.168. ...

  9. nagios npc安装后状态为off的解决方法

    1.检查ndo2db的进程是不是二个 nagios   16825  0.0  0.1   6784   396 ?        Ss   19:05   0:00 /usr/local/nagio ...

最新文章

  1. C++中的内联函数inline
  2. 数据中心的敏捷运维之路
  3. 7、 MySQL锁机制:数据库核心技术之一
  4. redis分布式锁实现原理_redis分布式锁实现分析与实践
  5. C++中的继承(派生)的一些误区
  6. 2018.12.27|区块链技术头条
  7. 华为2019 秋招笔试题
  8. 怎么把ppt文字大小设置一致_PPT基础入门技巧,这都不会?就别谈制作PPT了,学会瞬间提高档次...
  9. 我的世界服务器被无限循环怎么办,我的世界无限循环装置制作方法
  10. 进程互斥锁,队列,IPC进程间通信,生产者与消费者,线程,线程对象的属性,先行互斥锁...
  11. 面试题 05.08. 绘制直线
  12. mybatis-plus insertStrategy、updateStrategy、whereStrategy属性
  13. Java输出一个数组
  14. 深入浅出matplotlib(10):构造圆弧示意图
  15. Python之,评委打分。A~F六位参赛选手,去除最高与最低分之后的的评分为…
  16. 【c语言】翻52张扑克牌问题
  17. HTML(3):IE浏览器编程
  18. mybatipse 下载_Windows实用软件推荐(2)——下载工具
  19. ERP 学习笔记 - 生产模块
  20. Cesium第一次搭建环境地球无法显示问题

热门文章

  1. 超好看的情侣纪念日记录单页HTML自适应源码
  2. golang简介_Golang简介
  3. 杜教筛如何推式子/堆柿子
  4. 华为服务器上安装vm系统,云服务器安装vm教程
  5. outlook邮箱收到的附件(excel, word, ppt)不能正常打开的解决办法
  6. 用例图包含关系、扩展关系、泛化关系解析
  7. 蓝牙耳机哪个品牌性价比高?高性价比真无线蓝牙耳机
  8. R02-javaWeb-ServletConfigServletConfig
  9. 将来的你,将会感谢现在努力拼搏奋斗的自己------学习计划。
  10. [音乐天堂]Eventide