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 ...
随机推荐
- python 教程 第十八章、 Web编程
第十八章. Web编程 import urllib2 LOGIN = 'jin' PASSWD = 'Welcome' URL = 'https://tlv-tools-qc:8443/qcbin/s ...
- PHP获取月末时间
用php获取月末 $a_date = "2009-11-23"; echo date("Y-m-t", strtotime($a_date)); //第二种 ( ...
- IOS开发之关于NSString和NSMutableString的retainCount
1. 字符串常量 NSString *s = @"test"; NSLog(@"s:%lx",[s retainCount]); //fffffffffffff ...
- WPF DataGrid的LoadingRow事件
<Window x:Class="DataGridExam.MainWindow" xmlns="http://schemas.microsoft.c ...
- WPF获取控件内部的ScrollViewer,并控制ScrollViewer操作
//获取内部 ScrollViewer方法 public static T FindVisualChild<T>(DependencyObject obj) where T : Depe ...
- 微信小程序入门-指南针
微信小程序提供了众多的原生API接口,利用罗盘接口,做了个简单的指南针小程序,搜索小程序[X的实验室]可看效果. 实现方案 利用罗盘接口返回的[数据],转化为指南针偏移量[度数],利用CSS3 tra ...
- Qt打开外部程序和文件夹需要注意的细节(注意QProcess的空格问题,以及打开本地文件时,需要QUrl::fromLocalFile才可以)
下午写程序中遇到几个小细节,需要在这里记录一下. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 QProcess *process = new QProcess(this ...
- c#实现golang 的channel
使用.NET的 BlockingCollection<T>来包装一个ConcurrentQueue<T>来实现golang的channel. 代码如下: public clas ...
- ML:吴恩达 机器学习 课程笔记(Week3~4)
Logistic Regression Regularization Neural Networks: Representation
- Webpack Waringing Critical dependencies
报错信息如下: 出错原因先上图: 未注释部分使用了require的同时使用了es6的语法. 官方解释如下: 解决方法就是放开代码中的注释部分,不要使用es6语法