Problem K: Deadline

Time Limit: 2 Sec Memory Limit: 1280 MB

Submit: 1106 Solved: 117

[Submit][Status][Web Board]

Description

There are N bugs to be repaired and some engineers whose abilities are roughly equal. And an engineer can repair a bug per day. Each bug has a deadline A[i].

  Question: How many engineers can repair all bugs before those deadlines at least?

  1<=n<= 1e6. 1<=a[i] <=1e9

Input

There are multiply test cases.

   In each case, the first line is an integer N , indicates the number of bugs. The next line is n integers indicates the deadlines of those bugs.

Output

There are one number indicates the answer to the question in a line for each case.

Sample Input

4

1 2 3 4

Sample Output

1

这道题的意思就是每件事都有个deadline,你一天只能做一件事情,我肯定贪心,先做要先完成了事啊,这个需要的程序员最少,可是1e6恐怕会超时的,所以需要对数据进行预处理,大于n的肯定可以做完了,题解上讲可以O(n),用天数前缀和(s[i]-i+1)/i

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int b[MAXN];
int sum[MAXN];
int main()
{
int n;
while (~scanf("%d", &n)) {
int maxA,i,a;
memset(b, 0, sizeof(b));
for (i = 0; i < n; ++i) {
scanf("%d", &a);
if (a > n) {
continue;
}
++b[a];
if (a > maxA) {
maxA = a;
}
}
sum[0] = 0;
int ans = 1;
for (i = 1; i <= maxA; ++i) {
sum[i] = sum[i - 1] + b[i];
ans = max(ans, (sum[i] + i - 1) / i);
} printf("%d\n", ans);
} return 0;
}

HAZU校赛 Problem K: Deadline的更多相关文章

  1. 2018年浙江理工大学程序设计竞赛校赛 Problem I: 沙僧

    沙僧 思路: dfs序+差分数组 分层考虑,通过dfs序来查找修改的区间段,然后用差分数组修改 代码: #include<bits/stdc++.h> using namespace st ...

  2. 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)

    以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...

  3. 杭电多校第四场 Problem K. Expression in Memories 思维模拟

    Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262 ...

  4. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  5. SCNU省选校赛第二场B题题解

    今晚的校赛又告一段落啦,终于"开斋"了! AC了两题,还算是满意的,英语还是硬伤. 来看题目吧! B. Array time limit per test 2 seconds me ...

  6. 2015 GDUT校赛

    周末打了个GDUT的校赛,也是作为SCAU的一场个人排位. 比赛中竟然卡了个特判,1个半钟就切了5条了,然后一直卡. 还有其他两条可以做的题也没法做了,性格太执着对ACM来说也是错呀. 讲回正题 . ...

  7. HZNU第十二届校赛赛后补题

    愉快的校赛翻皮水! 题解 A 温暖的签到,注意用gets #include <map> #include <set> #include <ctime> #inclu ...

  8. 牛客网多校赛第9场 E-Music Game【概率期望】【逆元】

    链接:https://www.nowcoder.com/acm/contest/147/E 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524 ...

  9. BZOJ 3093: [Fdu校赛2012] A Famous Game

    3093: [Fdu校赛2012] A Famous Game Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 242  Solved: 129[Subm ...

随机推荐

  1. 【TensorFlow入门完全指南】神经网络篇·自动编码机

    自动编码机(Autoencoder)属于非监督学习,不需要对训练样本进行标记.自动编码机(Autoencoder)由三层网络组成,其中输入层神经元数量与输出层神经元数量相等,中间层神经元数量少于输入层 ...

  2. eclipse中代码注释及其他常用快捷键

    html代码注释/取消注释             Ctrl + Shift + c php代码注释/取消注释                 Ctrl + / (4)Ctrl+Shift+/ 说明: ...

  3. UML各种图总结

    UML(Unified Modeling Language)是一种统一建模语言,为面向对象开发系统的产品进行说明.可视化.和编制文档的一种标准语言.下面将对UML的九种图+包图的基本概念进行介绍以及各 ...

  4. python之道09

    整理函数相关知识点,写博客. 看代码写结果 1. def func(): for i in range(3): print(i) return 666 print(func()) # 0 1 2 66 ...

  5. Eclipse:Win10中设置Courier New字体

    问题:在Eclipse中设置字体的时候,没有找到Courier New字体.系统为Win10. 解决:Eclipse使用的字体为系统字体.在系统字体中有一部分是隐藏的.Courier New已经在系统 ...

  6. linux交换分区调整

      SWAP就是LINUX下的虚拟内存分区,它的作用是在物理内存使用完之后,将磁盘空间(也就是SWAP分区)虚拟成内存来使用.它和Windows系统的交换文件作用类似,但是它是一段连续的磁盘空间,并且 ...

  7. iOS8之后,UITableViewRowAction实现滑动多个按钮

    #pragma mark - View lifeCycle - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = ...

  8. Linux - mkdir -p a/b/c

    mkdir -p a/b/c -p  会循环创建

  9. XML 转 fastJSON

      import java.util.List; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Doc ...

  10. (70)zabbix telnet监控类型

    概述 zabbix监控的方式很多,例如前面讲到的agent.snmp以及后续后续要讲到ssh和今天要讲到的telnet.流程很简单,创建item-->配置ip.用户.密码.端口.脚本->z ...