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秒 ...
随机推荐
- 【剑指offer】求一组数据中最小的K个数
题目:输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,. *知识点:Java PriorityQueue 调整新插入元素 转自h ...
- inode引起的Linux无法创建新文件,磁盘空间不足
df -h,判断硬盘空间是否已经满了,占用率达100% ,就可以断定该分区满了. df -ia,占用率达100%,也会导致无法创建新文件.一般都是存在大量小文件引起的. inode包含文件的元信息,具 ...
- 爬虫:输入网页之后爬取当前页面的图片和背景图片,最后打包成exe
环境:py3.6 核心库:selenium(考虑到通用性,js加载的网页).pyinstaller 颜色显示:colors.py colors.py 用于在命令行输出文字时,带有颜色,可有可无. # ...
- List接口、Set接口和Map接口
1.List和Set接口继承自Collection接口,而Map不是继承的Collection接口 Map没有继承Collection接口,Map提供key到value的映射;一个Map中不能包含相同 ...
- vue-cli脚手架build目录中的build.js配置文件
该随笔收藏自: vue-cli脚手架build目录中的build.js配置文件 这个配置文件是命令npm run build 的入口配置文件,主要用于生产环境 由于这是一个系统的配置文件,将涉及很多的 ...
- liunx 部署 spring boot
Xshell for Xmanager Enterprise 4 (Build 0232)Copyright (c) 2002-2014 NetSarang Computer, Inc. All ri ...
- How can I manage the modules for python2 when python3 installed as well. In OSX
ref: https://stackoverflow.com/questions/53385448/how-can-i-manage-the-modules-for-python2-when-pyth ...
- py库:文本转为语音(pywin32、pyttsx)
http://blog.csdn.net/marksinoberg/article/details/52137547 Python 文本转语音 文本转为语音(使用Speech API) 需要安装 py ...
- 14-background
一.background-color:设置该元素的背景颜色 一共有三种:单词.rgb表示法.十六进制表示法 1.rgb:红色 绿色 蓝色 三原色 光学显示器,每个像素都是由三原色的发光原件组成的,靠明 ...
- 通过adb启动app应用
由于某些原因,我需要自动启动雷电模拟器里面的一个应用.(利用Windows任务计划) 怎么自启动雷电模拟器就不用说了,很简单. 自启动app我倒是不熟悉,我没用安卓方面的知识.再官网论坛上面查到了相关 ...