CCPC2019江西省赛-Problem G.Traffic
题目描述:
/*纯手打题面*/
Avin is observing the cars at a crossroads.He finds that there are n cars running in the east-west direction
with the i-th car passing the intersection at time a[i].There are another m cars running in the north-south
direction with the i-th car passing the intersection at time b[i].If two cars passing the intersections at
the same time,a traffic crash occurs.In order to achieve world peace and harmony,all the cars running in the
north-south direction wait the same time amount of integral time so that no two cars bump.You are asked the
minimum waiting time.
/*纯手打题面*/
Input
n m
a[i]
b[i]
(1<=n,m<=1000;1<=ai,bi<=1000)
Output
The minimum waiting time(integer).
题解心得:
啊啊啊啊啊啊啊啊啊啊啊啊,当时在比赛的时候翻了好久词典,终于把这个题目的意思大概搞懂了
然后和我们队的大佬讨论了好久
一开始爆搜O(N3)
然后想了好久奇奇怪怪的方法,分治什么的,然后就剪枝优化。
但是最后用标记法把时间复杂度压到了O(N2)。
大致思路:
枚举时间(一个循环)
在每个循环里标记a[i]所占的时间点(布尔数组c)
同时标记b[i]+t的时间点(布尔数组d)
接着c&&d;
就可以了。
这题真的水,不加剪枝也能AC。
代码:
以后附。
CCPC2019江西省赛-Problem G.Traffic的更多相关文章
- Problem G 宝石合成 (内蒙古14年省赛)
1117: Problem G 宝石合成 时间限制: 1 Sec 内存限制: 128 MB 提交: 18 解决: 4 [提交][状态][讨论版] 题目描写叙述 故事人物:豆豆强 走上致富之路的豆豆 ...
- 【贪心+中位数】【新生赛3 1007题】 Problem G (K)
Problem G Time Limit : 4000/2000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Sub ...
- 实验9:Problem G: 克隆人来了!
想要输出""的话: cout<<"A person whose name is \""<<name<<" ...
- 实验12:Problem G: 强悍的矩阵运算来了
这个题目主要是乘法运算符的重载,卡了我好久,矩阵的乘法用3个嵌套的for循环进行,要分清楚矩阵的乘法结果是第一个矩阵的行,第二个矩阵的列所组成的矩阵. 重载+,*运算符时,可以在参数列表中传两个矩阵引 ...
- 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem G: Check The Check(模拟国际象棋)
Problem G: Check The Check Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 10 Solved: 3[Submit][Statu ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem G
Problem G Good Teacher I want to be a good teacher, so at least I need to remember all the student n ...
- Problem G: If We Were a Child Again
Problem G: If We Were a Child AgainTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 14[Submi ...
- Problem G: Keywords Search
Problem G: Keywords SearchTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 10 Solved: 6[Submit][Status] ...
- BZOJ4977 八月月赛 Problem G 跳伞求生 set 贪心
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ4977 - 八月月赛 Problem G 题意 小明组建了一支由n名玩家组成的战队,编号依次为1到n ...
随机推荐
- flash导出正常清晰(无色差)GIF图片
前言: 这枚GIF算是半临摹作品.我使用的FLASH制作这个小动画,其实这类型的动画用AE做会更便捷. 进入主题前,先摆出个成品 教程结束,以上就是flash制作出来的小动画怎么导出正常清晰(无色差) ...
- Java之nio MappedByteBuffer的资源释放问题
使用nio的MappedByteBuffer映射内存, 在最后执行File.delete()方法的时候, 返回false, 即文件没有被删除. 原因是MappedByteBuffer在内存中也会创建 ...
- IdentityServer流程图与相关术语
概念图 apparch 最常见的交互是:浏览器与web应用程序通信web应用程序与web APIs进行通信基于浏览器的应用程序与web APIs通信原生应用与web APIs通信基于服务的应用程序 ...
- c# SQLHelper总汇
/// <summary> /// The SqlHelper class is intended to encapsulate high performance, /// scalabl ...
- RelativeSource 简述
原文:RelativeSource 简述 RelativeSource实现标记扩展,以描述绑定源相对于绑定目标的位置. <Binding> <Binding.RelativeSour ...
- String的本质是一个char*,只是以类的形式提供,使用起来比较方便
String的本质是一个char*,只是以类的形式提供,使用起来比较方便 Class String {private: char* m_data;}摘自<后台开发 核心技术与应用实践__徐晓鑫& ...
- Pytorch Code积累
2017 Python最新面试题及答案16道题 15个重要Python面试题 测测你适不适合做Python? torch.squeeze() Returns a tensor with all the ...
- Use Spring @Scheduled To Achieve Timing Task
Today I have a chance to use the @Scheduled to achieve a timing task.It is useful.Anyway,it was the ...
- RedHat 7.3 修改ASM磁盘绑定路径
RedHat 7中,很多命令发生了改变,绑定磁盘不再是start_udev,而是udevadm,具体绑定方式,请看另一篇博文: http://www.cnblogs.com/zx3212/p/6757 ...
- Python:Pandas学习
import pandas as pd import numpy as np s = pd.Series([1, 3, 6, np.nan, 44, 1]) df= pd.DataFrame(np.r ...