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. 关于representation的理解

    目前见过的定义的比较确切的是Yoshua Bengio在ACL2010的一篇paper中关于word representation的定义: " A word Representation i ...

  2. 最简单的访问google的办法

    我用的是猎豹浏览器,在工具下面的猎豹应用市场里面,搜索红杏,安装即可. 打开google产品地址时,如果地址栏里面右边的杏是绿色的,代表正常,如果是红色的,代表不正常. 可能是装了其他代理软件,如Sw ...

  3. 【随笔】js加载

    有时候,当发现js操作一个dom的时候,发现dom没有找到,这是由于html没有加载完就开始操作该dom的缘故,所以需要在html文档加载完后再加载js,于是我们可以这么做: js方法:window. ...

  4. java 学习写架构必会几大技术点

    java 学习写架构必会几大技术点 关于学习架构,必须会的几点技术 1. java反射技术 2. xml文件处理 3. properties属性文件处理 4. 线程安全机制 5. annocation ...

  5. Android 动画详解

    这次主要就介绍android动画,android动画目前分为三种形式,Tween Animation 这个只能应用于view对象上面的,Drawable Animation这个是帧动画,就是类似我们有 ...

  6. javascript中获取元素节点的文本

    <div id="test"> <strong>i'm strong</strong> </div> 1.elementNode.i ...

  7. linux服务器apache 一个IP,一个端口,建立多个网站的方法。

    找到apache-tomcat-6.0.14\conf\server.xml ,再services 后面添加此段代码: Xml代码 <!-- 此处  新增的项目配置-->  <Ser ...

  8. rest-assured : Restful API 测试利器 - 真正的黑盒单元测试(跟Spring-Boot更配哦,更新至spring-boot1.4.1)

    { "Author":"tomcat and jerry", "URL" :"http://www.cnblogs.com/tom ...

  9. [12]APUE:高级 I/O

    一.分散聚离(向量) I/O [a] readv / writev #include <sys/uio.h> ssize_t readv(int fd, const struct iove ...

  10. css3的transition过渡

    从*开始样式*,经过指定*时间*后,缓慢过渡到*结束样式* 语法:transition:要变化的属性名 持续时间 速度变化类型 延迟 强调:写在开始样式中 如何实现多个属性同时过渡:2种办法: 1. ...