问题 C: Frosh Week(2018组队训练赛第十五场)(签到)
问题 C: Frosh Week
时间限制: 4 Sec 内存限制: 128 MB
提交: 145 解决: 63
[提交][状态][讨论版][命题人:admin]
题目描述
music is blaring.
The event organizers are also very precise. They supply Zac with intervals of time when music will not be playing. These intervals are specified by their start and end times down to the millisecond.
Each task that Zac completes must be completed in one quiet interval. He cannot pause working on a task when music plays (he loses his train of thought). Interstingly, the lengths of the tasks and quiet intervals are such that it is impossible to finish more than one task per quiet interval!
Given a list of times ti (in milliseconds) that each task will take and a list of times Lj (in milliseconds) specifying the lengths of the intervals when no music is being played, what is the maximum number of tasks that Zac can complete?
输入
number of time intervals when no music is played. The second line consists of a list of integers t1,t2,...,tn indicating the length of time of each task. The final line consists of a list of times L1,L2,... ,Lm indicating the length of time of each quiet interval when Zac is at work this week.
You may assume that 1≤n;m≤200,000 and 100,000≤ti,Lj≤199,999 for each task i and each quiet interval j.
输出
样例输入
5 4
150000 100000 160000 100000 180000
190000 170000 140000 160000
样例输出
4 很简单的模拟题,开始我想的是存下所有的时间,然后sort,把各自大的放前面,进行比较,虽然担心了时间,但是看到4s还是交了,果不其然t了。Orz 后面一看,不就1e5到2e5的时间范围吗,直接用值哈希,跑一遍。
#include<bits/stdc++.h> using namespace std; int task[];
int work_num[];
const int limit = ; int main()
{
int n,m;
scanf("%d%d",&n,&m);
int temp;
memset(task,,sizeof(task));
memset(work_num,,sizeof(work_num));
for(int i=;i<n;i++)
{
scanf("%d",&temp);
task[temp-limit]++;
}
for(int i=;i<m;i++)
{
scanf("%d",&temp);
work_num[temp - limit]++;
}
int ans = ;
int cnt = ;
for(int i=limit;i>=;i--)
{
if(work_num[i])cnt+=work_num[i];
if(cnt != )
{
if(task[i])
{
int minn = min(task[i],cnt);
ans += minn;
cnt -= minn;
}
}
}
printf("%d\n",ans);
} /**************************************************************
Problem: 5129
User: DP18
Language: C++
Result: 正确
Time:68 ms
Memory:2476 kb
****************************************************************/
问题 C: Frosh Week(2018组队训练赛第十五场)(签到)的更多相关文章
- 问题 J: Palindromic Password ( 2018组队训练赛第十五场) (简单模拟)
问题 J: Palindromic Password 时间限制: 3 Sec 内存限制: 128 MB提交: 217 解决: 62[提交][状态][讨论版][命题人:admin] 题目描述 The ...
- 备战省赛组队训练赛第十八场(UPC)
传送门 题解:by 青岛大学 A:https://blog.csdn.net/birdmanqin/article/details/89789424 B:https://blog.csdn.net/b ...
- 备战省赛组队训练赛第十六场(UPC)
传送门 题解: by 烟台大学 (提取码:8972)
- 备战省赛组队训练赛第十四场(UPC)
codeforces:传送门 upc:传送门 外来题解: [1]:https://blog.csdn.net/ccsu_cat/article/details/86707446 [2]:https:/ ...
- UPC Contest RankList – 2019年第二阶段我要变强个人训练赛第十五场
传送门 A: Colorful Subsequence •题意 给一个长为n的小写字母序列,从中选出字母组成子序列 问最多能组成多少种每个字母都不相同的子序列 (不同位置的相同字母也算是不同的一种) ...
- UPC个人训练赛第十五场(AtCoder Grand Contest 031)
传送门: [1]:AtCoder [2]:UPC比赛场 [3]:UPC补题场 参考资料 [1]:https://www.cnblogs.com/QLU-ACM/p/11191644.html B.Re ...
- 2018牛客网暑假ACM多校训练赛(第五场)H subseq 树状数组
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round5-H.html 题目传送门 - https://www.no ...
- 2018牛客网暑假ACM多校训练赛(第五场)F take 树状数组,期望
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round5-F.html 题目传送门 - https://www.no ...
- UPC Contest RankList – 2019年第二阶段我要变强个人训练赛第十四场
A.JOIOJI •传送门 [1]:BZOJ [2]:洛谷 •思路 在一个区间(L,R]内,JOI的个数是相等的,也就是R[J]-L[J]=R[O]-L[O]=R[I]-L[I], 利用前缀和的思想, ...
随机推荐
- nginx+ssl 服务器 双向认证
项目后台服务器采用nginx+tomcat 负载均衡架构 不久 访问协议有http升级为https 对服务器认证采用沃通的ssl证书 nginx ssl证书安装 参照沃通官方文档 他们有技术支持沟通 ...
- ssh 登录报错 packet_write_wait: Connection to x.x.x.x port 22: Broken pipe
问题 更新个人博客文章时遇到:Error: packet_write_wait: Connection to 192.30.253.113 port 22: Broken pipe packet_wr ...
- 设置外部查找工具来索引 Confluence 6
任何网页的 crawler 工具都可以被用来索引你的 Confluence 站点中的内容.如果你希望注册用户才能够查看的内容也被索引的话,你需要为你的 Confluence 创建一个只被 crawl ...
- vue三大框架
vue 前端三大新框架: Angular.js------Google研发 缺点: 学习成本高.最早研发 严谨 React.js facebook.com (脸书)自主研发 开源 j ...
- Django框架之第三篇模板语法(重要!!!)
一.什么是模板? 只要是在html里面有模板语法就不是html文件了,这样的文件就叫做模板. 二.模板语法分类 一.模板语法之变量:语法为 {{ }}: 在 Django 模板中遍历复杂数据结构的关键 ...
- java 自动包装功能
基本类型直接存储在堆栈中 基本类型所具有的包装容器,使得可以在堆中创建一个非基本对象,用来表示对应的基本类型 基本类型与包装容器类对应如下:boolean Booleanbyte Byte short ...
- java-HTML&javaSkcript&CSS&jQuery&ajax( 八)
一.JavaScript教程笔记 1.在web页面中一般使用JavaScript脚本语言,支持跨平台,跨浏览器,驱动网页,与用户交互.另外Node.js把JavaScript引入到了服务器端. Jav ...
- ajax---获取XMLHttpReuquest 对象
ajax的异步和同步(Asynchronus Javascript and Xml) 同步:一个时间段只能干一件事:即按部就班,一件事一件事的做. 异步:相同的时间段做多件事,同时进行.依靠 XMLH ...
- extjs5(项目中文件的加载过程)
现在来看看js类加载过程.如下图所示: 1、首先:浏览器中输入 localhost:1841 ,调用 index.html; <!DOCTYPE HTML> <html> &l ...
- gitlab使用--汉化及修改端口
汉化思路:去gitlab汉化社区下载对应的汉化版本,这个文件和当前版本对比形成一个补丁,打入到当前配置文件中 1.查看当前gitlab版本 head -1(数字) /opt/gitlab/ve ...