问题 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], 利用前缀和的思想, ...
随机推荐
- Swift 学习- 02 -- 基础部分2
class NamedShape{ var numberOfSides: Int = 0 var name: String init(name: String) { self.name = name ...
- 阿里云-AliRepo
<mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name&g ...
- Oracle管理文件OMF (oracle managed files)
简化dba的管理操作 1:启用 omf 23:16:04 SYS@orcl> show parameter DB_CREATE_FILE_DEST NAME TYPE VALUE ------- ...
- Confluence 6 修改默认空间标识图片
空间标识图片在边栏上的站点目录(Sites Directory)中作为图标进行显示.默认的空间标识图片将会应用到所有的空间中,如果你没有自定义的空间标识被定义的话,请查看 Configure the ...
- Android 基础 二 四大组件 Activity
Activity Intent IntentFilter 一理论概述 一. Activity 用来提供一个能让用户操作并与之交互的界面. 1.1 启动 startActivity(Intent int ...
- Es6对象的扩展和Class类的基础知识笔记
/*---------------------对象的扩展---------------------*/ //属性简写 ,属性名为变量名, 属性值为变量的值 export default functio ...
- Python基础之函数二
函数的嵌套 通过名字就能理解,函数里是还可以套着函数用的.这么牛,下面就来看看几段代码,看看是怎么回事.注意:函数一定是先定义后使用. x=1234 def f1(): #定义一个主函数 x = 1 ...
- vue 的动画
1.vue 的动画流程分为enter,和leave分别对应以下两幅图 <!doctype html><html lang="en"><head> ...
- node.js 框架express关于报错页面的配置
1.声明报错的方法,以及相对应的页面 //把数据库的调用方法配置到请求中 server.use((req, res, next) => { //把数据库存入req中 req.db = db; / ...
- Python中的xxx == xx是否等价于xxx is xxx
先上代码: >>> a = 1 >>> b = 1 >>> a is b True >>> a == b True what? ...