问题 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], 利用前缀和的思想, ...
随机推荐
- 2018 github热门项目
github流行的几个项目,我们来学习一下. 1. developer-roadmap-chinese image.png 项目简介:2018年web程序员路线中文版, 这个仓库里包含了一些前端,后端 ...
- Windows下Oracle 11g的下载与安装
Windows下Oracle的下载与安装 一.Oracle下载 官网地址:http://www.oracle.com/technetwork/database/enterprise-edition/d ...
- Confluence 6 尝试从 XML 备份中恢复时解决错误
错误可能是因为数据库突然不可访问而产生.也有可能是你备份文件有问题,你需要找到你 XML 备份文件中违反数据库规定的记录修改这个记录后再创建一个新的 XML 备份: 在实例开始恢复的时候,请按照下面的 ...
- Java语法基础常见疑惑解答
1. 类是java的最小单位,java的程序必须在类中才能运行 2. java函数加不加static有何不同 java中声明为static的方法称为静态方法或类方法.静态方法可以直接调用静态方法,访问 ...
- Linux 用户切换、修改用户名、修改密码
一.用户切换 "$":普通用户提示符 "#":root用户提示符 1.普通用户到root: 方式一:命令:su然后输入root密码 此种方式只是切换了root身 ...
- 【python】内存相关
1. /proc/pid/status 可以查看进程相关的详细信息,当内存异常时可查看 参考:http://blog.csdn.net/beckdon/article/details/4849190 ...
- XSS-HTML&javaSkcript&CSS&jQuery&ajax-CSS
CSS 1.表单的处理 <style> table, td, th{ border:1px; solid green;} th{ background-color:green; color ...
- C++ Primer 笔记——命名空间
1.我们既可以用 using 声明整个空间,也可以声明部分名字. using namespace std; using std::cout; 2.头文件不应包含 using 声明,因为头文件会拷贝到所 ...
- ORACLE EHCC(exadata hybrid columnar compression)
目录: 1. 简介 2. 压缩方式及压缩比 3. 压缩哪些数据 4. 可能有用的脚本 一.简介 EHCC(Exadata Hybrid Columnar Compression),是Oralce 数据 ...
- 目标检测中的mAP
一.IOU的概念 交集和并集的比例(所谓的交集和并集,都是预测框和实际框的集合关系).如图: 二.Precision(准确率)和Recall(召回率)的概念 对于二分类问题,可将样例根据其真实类别和预 ...