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 ...
随机推荐
- C#WPF 如何绘制几何图形 图示教程 绘制sin曲线 正弦 绘制2D坐标系 有图有代码
原文:C#WPF 如何绘制几何图形 图示教程 绘制sin曲线 正弦 绘制2D坐标系 有图有代码 C#WPF 如何绘制几何图形? 怎么绘制坐标系?绘制sin曲线(正弦曲线)? 这离不开Path(Syst ...
- Asp.NET的目的是学习
一.概观 二.具体介绍 1.Request对象 Request对象是用来获取client在请求一个页面或传送一个Form时提供的全部信息.这包含可以标识浏览器和用户的HTTP变量.存储在client的 ...
- Apache Commons Pool 故事一则 专题
Apache Commons Pool 故事一则 最近工作中遇到一个由于对commons-pool的使用不当而引发的问题,习得正确的使用姿势后,写下这个简单的故事,帮助理解Apache Commons ...
- Unity3D它Button包
原来难,转载请注明切换: http://blog.csdn.net/u012413679/article/details/26354715 ---- kosion 这里如果,你己经配置好了Unity3 ...
- 安德鲁斯Toast它们的定义和防止重复显示器
Toast安卓系统,当用户错误或功能运行完成,提示,要求用户,它不集中,并且将在一定时间内消失.然而,在用户继续误(如登录,password错)当次,将有多个Toast创建.系统会把这些toast放进 ...
- node.js学习笔记之json数据转string
Node.js中的JSON问题 var str = '{"dir":"kunhony","param":"archive&qu ...
- WPF实现选项卡效果(1)——使用AvalonDock
原文:WPF实现选项卡效果(1)--使用AvalonDock 简介 公司最近一个项目,软件采用WPF开发,需要实现类似于VS的选项卡(或者是浏览器的选项卡)效果.搜寻诸多资料后,发现很多同仁推荐Ava ...
- CentOS6.5优盘安装
从CentOS6.5开始直接把iso文件写入u盘就可实现优盘安装 windows平台:1.用UltraISO打开iso(如:CentOS-6.5-x86_64-bin-DVD1.iso)2.然后点“启 ...
- JNDI(Java Naming and Directory Interface)
# 前言 内容基本拷贝,整理出来,方便以后回忆. # What The Java Naming and Directory Interface™ (JNDI) is an application pr ...
- box-shadow 与 filter:drop-shadow 详解及技巧
box-shadow 在前端的 CSS 编写工作想必十分常见.但是 box-shadow 除去它的常规用法,其实还存在许多不为人知的奇技淫巧. 喜欢 markdown 版本的可以戳这里. box-sh ...