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 ...
随机推荐
- 常见的选择<数据源协议,委托协议>(IOS发展)
-常见的选择必须满足这两个协议,约定实施.一个为数据源协议 -托付协议负责控制控件UI.事件响应, 实现可选 -数据源协议负责控件与应用数据模型的桥梁,一般必须实现 @interface ViewCo ...
- vc有关 directx组态,和dxsdk_extras(directshow)
2009-11-10 0:28 此文章:自己编写 转载于<汤姆&杰瑞> DirectShow 1 -- 下载与VC配置 1 DirectX SDK9 Directshow sd ...
- (转)移动端自定义返回上一页的方法:history
在实际的应用中,我们常常需要实现在移动app和浏览器中点击返回.后退.上一页等按钮实现自己的关闭页面.调整到指定页面或执行一些其它操作的需求. 那在代码中怎样监听当点击微信.支付宝.百度糯米.百度钱包 ...
- SwiftCafe 咖啡时光 - 了解 Swift 中的闭包
闭包(Closure) 是现代开发语言的必备特性,极大的提高了我们的开发效率. 关于闭包,你可以把它理解为一种特殊的变量或对象.简而言之,我们通常的对象,里面存储的是变量或对象的值,而闭包里面存储的是 ...
- 基于IdentityServer4的单点登录——项目基本结构与流程
组成 IdentityServer,Api和Client(客户端,asp .net core)本文以官方demo:https://github.com/IdentityServer/IdentityS ...
- Nancy Web框架
原文 Nancy Web框架 Nancy框架 一.创建第一个Nancy应用 二.探索Nancy的module 1. 模块能够在全局被发现 2. 使用模块为路由创建一个根 三.定义路由 1. 方法 2. ...
- Android adb shell 无法启动:insufficient permissions for device
解决办法1:lsusb查看vendorId号,然后在/etc/udev/rules.d/目录下增加(或修改)51-android.rules文件.增加一条记录:SUBSYSTEM=="usb ...
- Win10《芒果TV》商店版更新v3.2.3:新增应用内意见反馈、播放重试、透明磁贴
在2016圣诞节临近之际,<芒果TV>UWP版迅速更新v3.2.3版,主要是新增应用内意见反馈提交功能.播放重试.透明磁贴.动态磁贴等功能,进一步优化稳定性.视觉细节.运行速度. 芒果TV ...
- SQLite Expert Professional 打开加密SQLite数据库
原文 SQLite Expert Professional 打开加密数据库 (已修改) 版本:sqlite expert professional 4.2.0.739 (x86) 目的:用SQLite ...
- webmethod基本认知
六种控件统称flow step insert/invoke 插入services,类似调用函数 BRANCH 分支结构 参数名在switch定义 子参数以label确定 注意:确保label唯一,否则 ...