题目链接

题意:有一个飞机场。有两条待飞跑到w和e。一条起飞跑道。每一时刻仅仅能起飞一架飞机,然后有w[i]和e[i]架飞机进入w和e跑道。飞机编号从0開始,问说怎样安排起飞能够使得飞机编号的最大值最小。

思路:仅仅要二分搜索,找到最小的答案就能够了。注意跑道上为0时。是没有飞机起飞的。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; const int MAXN = 5005; int t;
int A[MAXN], B[MAXN]; int judge(int n) {
int cura = 0, curb = 0, num = 0;
int a, b;
for (int i = 0; i < t; i++) {
cura += A[i];
curb += B[i];
a = max(cura - n, 0);
b = max(curb - n, 0);
if (a + b > num)
return false;
if (cura > 0 && curb > 0 && cura + curb > num)
num++;
else if (cura > 0 && curb == 0)
cura--;
else if (cura == 0 && curb > 0)
curb--;
}
return true;
} int main() {
int cas;
scanf("%d", &cas);
while (cas--) {
scanf("%d", &t);
for (int i = 0; i < t; i++)
scanf("%d%d", &A[i], &B[i]); int L = 1, R = MAXN * 20, mid;
while (L < R) {
mid = (R + L) / 2;
if (judge(mid))
R = mid;
else
L = mid + 1;
}
printf("%d\n", L - 1);
}
return 0;
}

UVA1450-Airport的更多相关文章

  1. ios实用wifi分析仪——AirPort

    AirPort(wifi分析仪) android系统上免费的wifi分析仪很多,但是当我在AppStore上搜索时,找了半天也没找到想要的,后来还是问前辈才知道一款非常好用的app——AirPort, ...

  2. Airport(未解决。。。)

    Airport Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  3. HDU 5046 Airport(DLX反复覆盖)

    HDU 5046 Airport 题目链接 题意:给定一些机场.要求选出K个机场,使得其它机场到其它机场的最大值最小 思路:二分+DLX反复覆盖去推断就可以 代码: #include <cstd ...

  4. (中等) HDU 5046 Airport ,DLX+可重复覆盖+二分。

    Description The country of jiuye composed by N cites. Each city can be viewed as a point in a two- d ...

  5. word20170106在机场 At the airport有用的词和句子

    有用的词: airport terminal: 航站楼 domestic flight: 国内航班 international flight: 国际航班 checked luggage: 托运行李 c ...

  6. UVA - 11374 - Airport Express(堆优化Dijkstra)

    Problem    UVA - 11374 - Airport Express Time Limit: 1000 mSec Problem Description In a small city c ...

  7. UVA 11168 Airport(凸包)

    Airport [题目链接]Airport [题目类型]凸包 &题解: 蓝书274页,要想到解析几何来降低复杂度,还用到点到直线的距离公式,之后向想到预处理x,y坐标之和,就可以O(1)查到距 ...

  8. English Conversation – Checking in at an airport

    English Conversation – Checking in at an airport Share Tweet Share Tagged With: Ben Franklin Exercis ...

  9. 一颗可靠的时间胶囊:苹果AirPort Time Capsule测评

    http://sspai.com/24181/ 如何从 Time Machine 备份恢复数据? AirPort Time Capsule能轻松完成备份,自然也少不了方便地恢复备份.一般常见的恢复备份 ...

  10. airport 抓包

    链接airport命令: ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources ...

随机推荐

  1. Python 获取时间戳

    Python 获取时间通过 time 模块 如下代码,是通过获取当前的时间,按照格式输出 Python默认获取当前的时间返回的都是时间的元组,下面是元组的,字符串时间的一个转换输出 # -*- cod ...

  2. 数据备份--dump(此作者有许多有用的博客文章)

    数据中 心操作大量的数据.当遭到破坏时,这就是一场灾难.这时候需要备份来恢复,及时你又大量的备份数据都没用,备份也肯定不是在浪费时间.你也许很幸运从 来没有经历过数据丢失.但是, 由于这种事情极少发生 ...

  3. SLF4J warning or error messages and their meanings(转)

    The method o.a.commons.logging.impl.SLF4FLogFactory#release was invoked. Given the structure of the ...

  4. 基于visual Studio2013解决面试题之1401冒泡排序

     题目

  5. 小W与网格

    lucas定理 http://www.cnblogs.com/vongang/archive/2012/12/02/2798138.html 题目:http://hihocoder.com/conte ...

  6. android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 3

           今天在写一个小项目的数据库部分的功能时,出现了一个这样的问题:java.lang.RuntimeException: Failure delivering result ResultIn ...

  7. Matlab,Visio等生成的图片的字体嵌入问题解决方法

    确保所有字体嵌入,是生成高质量学术论文的必要条件.但是在Windows下,总会遇到Matlab或Visio生成字体没有嵌入的问题,当然这个问题的解决办法有很多(例如,对于Visio可以这样做:直接拷贝 ...

  8. ASP.NET - 记住滚动条的位置

    MaintainScrollPositionOnPostback ="true" 如果是滚动条在最下面,那么如果刷新页面,滚动条回到最上面. 使用这个属性之后,滚动条会在刷新之前的 ...

  9. TCP与UDP在socket编程中的区别 (网络收集转载)

    http://blog.chinaunix.net/uid-26421509-id-3814684.html 一.TCP与UDP的区别 基于连接与无连接  对系统资源的要求(TCP较多,UDP少)  ...

  10. res/drawable目录

    在Android Eclipse项目中res/目录下包含有drawable-ldpi/,drawable-mdpi/,drawable-hdpi/,drawable-xhdpi/目录,这几个目录的后缀 ...