题目描述:

  /*纯手打题面*/
  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的更多相关文章

  1. Problem G 宝石合成 (内蒙古14年省赛)

    1117: Problem G 宝石合成 时间限制: 1 Sec  内存限制: 128 MB 提交: 18  解决: 4 [提交][状态][讨论版] 题目描写叙述 故事人物:豆豆强 走上致富之路的豆豆 ...

  2. 【贪心+中位数】【新生赛3 1007题】 Problem G (K)

    Problem G Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Sub ...

  3. 实验9:Problem G: 克隆人来了!

    想要输出""的话: cout<<"A person whose name is \""<<name<<" ...

  4. 实验12:Problem G: 强悍的矩阵运算来了

    这个题目主要是乘法运算符的重载,卡了我好久,矩阵的乘法用3个嵌套的for循环进行,要分清楚矩阵的乘法结果是第一个矩阵的行,第二个矩阵的列所组成的矩阵. 重载+,*运算符时,可以在参数列表中传两个矩阵引 ...

  5. 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem G: Check The Check(模拟国际象棋)

    Problem G: Check The Check Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 10  Solved: 3[Submit][Statu ...

  6. 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 ...

  7. 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 ...

  8. Problem G: Keywords Search

    Problem G: Keywords SearchTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 10 Solved: 6[Submit][Status] ...

  9. BZOJ4977 八月月赛 Problem G 跳伞求生 set 贪心

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ4977 - 八月月赛 Problem G 题意 小明组建了一支由n名玩家组成的战队,编号依次为1到n ...

随机推荐

  1. Angular组件间的数据传输

    解法一 概括和流程 定义了两个组件,data-transfer-two和data-transfer-two-child,由data-transfer-two引用data-transfer-two-ch ...

  2. shell脚本自动化安装LAMP

    #!/bin/bash#auto make install LAMP#by authors yehailun #arp和apr-util依赖APR_FILES=apr-1.6.2.tar.gz APR ...

  3. KVM虚拟化知识的一些笔记

    一.KVM介绍 KVM:运行在内核空间,提供CPU 和内存的虚级化,以及客户机的 I/O 拦截.Guest 的 I/O 被 KVM 拦截后,交给 QEMU 处理. QEMU:修改过的为 KVM 虚机使 ...

  4. mysql数据库编码、字段编码、表编码 专题

    CREATE DATABASE `mybatis-subject` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */ 其中的 ...

  5. AY的Dapper研究学习-基本入门-C#开发-aaronyang技术分享

    原文:AY的Dapper研究学习-基本入门-C#开发-aaronyang技术分享 ====================www.ayjs.net       杨洋    wpfui.com      ...

  6. JavaScript eval() 函数,计算某个字符串,并执行其中的的 JavaScript 代码。

    JavaScript eval() 函数,计算某个字符串,并执行其中的的 JavaScript 代码. 适合用于计算器的计算,等. 例子: eval("x=10;y=20;document. ...

  7. Win10如何关闭自动更新服务

    原文:Win10如何关闭自动更新服务 第一步: 小娜搜索"gpedit.msc",进入本地计算机策略设置. 第二步: 找到策略位置:本地计算机策略-计算机配置-管理模板-Windo ...

  8. HLS(HTTP Live Streaming)学习和探讨

    Introduction HTTP Live Streaming lets you send audio and video over HTTP from an ordinary web server ...

  9. 《译文》借助OCR和神经网络,用JavaScript识别验证码

    昨天发现的了一段非常令人惊奇的JavaScript代码,是由ShaunF编写的automatically solves captchas,一个专门应用在Megaupload网站的Greasemonke ...

  10. 使用dumpbin命令查看dll导出函数及重定向输出到文件(VS自带)

    以前查看dll导出函数,一般使用Viewdll等第三方工具.但由于Viewdll采用dephi编写,因此仅能查看32位的dll.其实微软已经帮我们提供一个查看dll导出函数的命令,嵌在VS开发环境中, ...