CSU 1684-Disastrous Downtime
题目链接: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的更多相关文章
- 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 ...
- NCPC 2015 October 10, 2015 Problem D
NCPC 2015Problem DDisastrous DowntimeProblem ID: downtimeClaus Rebler, cc-by-saYou’re investigating ...
- 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 ...
- csu 1812: 三角形和矩形 凸包
传送门:csu 1812: 三角形和矩形 思路:首先,求出三角形的在矩形区域的顶点,矩形在三角形区域的顶点.然后求出所有的交点.这些点构成一个凸包,求凸包面积就OK了. /************** ...
- CSU 1503 点到圆弧的距离(2014湖南省程序设计竞赛A题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1503 解题报告:分两种情况就可以了,第一种是那个点跟圆心的连线在那段扇形的圆弧范围内,这 ...
- CSU 1120 病毒(DP)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1120 解题报告:dp,用一个串去更新另一个串,递推方程是: if(b[i] > a ...
- CSU 1116 Kingdoms(枚举最小生成树)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1116 解题报告:一个国家有n个城市,有m条路可以修,修每条路要一定的金币,现在这个国家只 ...
- CSU 1113 Updating a Dictionary(map容器应用)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 解题报告:输入两个字符串,第一个是原来的字典,第二个是新字典,字典中的元素的格式为 ...
- CSU 1333 Funny Car Racing (最短路)
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1333 解题报告:一个图里面有n个点和m条单向边,注意是单向边,然后每条路开a秒关闭b秒 ...
随机推荐
- ubuntu server资料
2.改变键盘布局 sudo dpkg-reconfigure keyboard-configuration 或sudo vim /etc/default/keyboard,修改XKBLAYOUT变量的 ...
- 学习笔记之Naive Bayes Classifier
Naive Bayes classifier - Wikipedia https://en.wikipedia.org/wiki/Naive_Bayes_classifier In machine l ...
- Python微信
""" Description: 需要提供以下三个信息,在申请到的微信企业号当中可以找到 agentid corpid corpsecret Author:Nod Dat ...
- 手动卸载CAD 删除残留文件 清理遗留的文件
手动卸载基于 AutoCAD 产品的文件,从而删除所有残留文件. 清理安装失败所遗留的文件. 一.解决方案: 通过"控制面板"卸载该程序. 删除以下位置残留的 AutoCAD 文件 ...
- 异步启动solidworks
两种方法: SldWorks App = new SldWorks(); App.Visible = true; //SldWorks.Application.24是2016 // App = (Sl ...
- 全面了解Ngnix的主要应用的场景
前言 本文只针对 Nginx 在不加载第三方模块的情况能处理哪些事情,由于第三方模块太多所以也介绍不完,当然本文本身也可能介绍的不完整,毕竟只是我个人使用过和了解到过得.所以还请见谅,同时欢迎留言交流 ...
- Laravel中队列的使用
以laravel5.5为例子: 1.配置队列:composer require "predis/predis:~1.0" a.在ENV中配置:QUEUE_DRIVER=redis ...
- ASCS HA
Please let us know what do you mean by "the PAS can not be accessed", what error did you f ...
- IDEA导入Eclipse项目
目录 一.导入项目 二.启动项目 一.导入项目 1.欢迎界面,选择Import Project 2.选择源码的位置,点击OK 3.选择Eclipse模型,点击Next 4.默认选择,点击Next 5. ...
- leetcode169
public class Solution { public int MajorityElement(int[] nums) { Dictionary<int, int> dic = ne ...