Constructing Roads In JGShining's Kingdom  HDU1025

题目主要理解要用LCS进行求解!

并且一般的求法会超时!!要用二分!!!

最后蛋疼的是输出格式的注意(直接报错误!!!)

 #include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int a[],dp[];
int main()
{
int n,i,a1,b1,len,j,d=,left,right,mid;
while(scanf("%d",&n)!=EOF)
{
for(i=;i<n;i++)
{
scanf("%d%d",&a1,&b1);
a[a1]=b1;
}
dp[]=-;
len=;
for(i=;i<=n;i++)
{
if(dp[len]<=a[i])
{
len++;
dp[len]=a[i];
}
else
{
left=;
right=len;
while(right-left>)
{
mid=(left+right)/;
if(a[i]>dp[mid])
left=mid;
else
right=mid;
}
dp[right]=a[i];
}
}
printf("Case %d:\n",++d);
if(len>1)
printf("My king, at most %d roads can be built.\n\n",len);
else
printf("My king, at most %d road can be built.\n\n",len);//没有这个,直接报错误!!!找了好久啊。。。
}
return ;
}

Constructing Roads In JGShining's Kingdom(HDU1025)(LCS序列的变行)的更多相关文章

  1. hdu-1025 Constructing Roads In JGShining's Kingdom(二分查找)

    题目链接: Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)     Memory Li ...

  2. [ACM] hdu 1025 Constructing Roads In JGShining's Kingdom (最长递增子序列,lower_bound使用)

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  3. HDU 1025 Constructing Roads In JGShining's Kingdom(二维LIS)

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  4. hdu--(1025)Constructing Roads In JGShining's Kingdom(dp/LIS+二分)

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  5. Constructing Roads In JGShining's Kingdom(HDU 1025 LIS nlogn方法)

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  6. hdu 1025:Constructing Roads In JGShining's Kingdom(DP + 二分优化)

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  7. HDOJ(HDU).1025 Constructing Roads In JGShining's Kingdom (DP)

    HDOJ(HDU).1025 Constructing Roads In JGShining's Kingdom (DP) 点我挑战题目 题目分析 题目大意就是给出两两配对的poor city和ric ...

  8. HDU 1025 Constructing Roads In JGShining's Kingdom[动态规划/nlogn求最长非递减子序列]

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  9. HDU 1025:Constructing Roads In JGShining's Kingdom(LIS+二分优化)

    http://acm.hdu.edu.cn/showproblem.php?pid=1025 Constructing Roads In JGShining's Kingdom Problem Des ...

随机推荐

  1. PDFsharp Samples

    http://www.pdfsharp.net/wiki/PDFsharpSamples.ashx http://www.pdfsharp.net/?AspxAutoDetectCookieSuppo ...

  2. HR开发 SuccessFactors与HCM数据映射

    SuccessFactors Employee Central ----->> HCM 增强点 ES_PAOCF_EC_TOOLS HCM ----->> SuccessFac ...

  3. ubuntu新建用户无法登陆

    使用sudo adduser 创建用户,不存在无法登陆问题,如果使用useradd创建用户xx,需要在新建home目录下建立用户目录. 同时,需要修改用户目录的属主,命令:chown xx:xx   ...

  4. Ubuntu15下mysql5.6.25解决不支持中文的办法

    apt-get install 安装的,不是源码包安装的mysql 1 修改mysql的配置文件 /etc/mysql/conf.d/mysql.cnf 在[mysql]的下方加入如下语句:(注:这个 ...

  5. mysql 简单优化方法

    优化步骤:1.查看SQL是否可以优化.2.查看索引是否可以优化.3.查看表结构是否可以优化. show table status from databases like 'tablename%'; / ...

  6. PHP获取具有相同name的多个input表单信息

    首先是表单应该这样写,注意每个 name="name[]"后面是有一个方括号的.这是PHP特有的获取具有相同name的多个input元素value的方法.(复选框也是采用这种方法) ...

  7. js分秒必争

    将函数和对象合写在一起时,函数就变成了“方法”(method): //当函数赋值给对象的属性,我们称之为 //方法.所有的JavaScript的对象都含有方法 var a=[];        //创 ...

  8. jQueryAjax笔记

    ajax优点:能在不刷新整个页面的前提下更新数据,使用户操作与服务器响应异步化. ajax缺点:破坏浏览器“前进”.“后退”按钮的正常功能,搜索引擎爬虫不能理解那些奇怪的JS代码和因此引起的页面内容的 ...

  9. iOS—如何申请苹果公司开发者账号流程详细图文介绍(包括邓白氏编码的申请方法详细介绍)

    我们要申请开发者账号,首先就需要先注册一个苹果的apple id,然后再这个账号的基础上去继续,这个相信大家都知道 这是申请appleid的地址:https://appleid.apple.com/a ...

  10. [C#.net]PostMessage与SendMessage的区别

    用 PostMessage.SendNotifyMessage.SendMessageCallback 等异步函数发送系统消息时,参数里不可以使用指针,因为发送者并不等待消息的处理就返回,接受者还没处 ...