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. 深度学习(dropout)

    other_techniques_for_regularization 随手翻译,略作参考,禁止转载 www.cnblogs.com/santian/p/5457412.html Dropout: D ...

  2. CentOS下的Memcache安装步骤(Linux+Nginx+PHP+Memcached)

    一.源码包准备 服务器端主要是安装memcache服务器端下载:http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz另外,Memca ...

  3. RPC学习----Thrift快速入门和Java简单示例

    一.什么是RPC? RPC(Remote Procedure Call Protocol)——远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议. RPC协议 ...

  4. jQuery Mobile 可折叠

    可折叠的内容块 可折叠(Collapsibles)允许您隐藏或显示内容 - 对于存储部分信息很有用. 如需创建可折叠的内容块,请向某个容器分配 data-role="collapsible& ...

  5. VSS 的修复和扫描

    关闭所有连接到VSS的客户端如:VSS客户端及VS开发工具,在命令行模式下,运行这个方法: "C:\Program Files (x86)\Microsoft Visual SourceSa ...

  6. 使用 Sandcastle 生成代码帮助文档

    使用 Sandcastle可以生成MSDN风格的帮助文档,生成的帮助文档既可以是chm文档,也可以是MS Help 2.x帮助文档. 1 下载并安装Sandcastle Sandcastle下载地址为 ...

  7. 分析‖为什么越来越多厂商开始发力VR一体机?

    2015年下半年,国内VR头显市场的主旋律还是PC头显和手机盒子.到了2016年上半年,一体机逐渐上位,成为发布会上的主角. 近期IDEALENS启视在北京召开发布会,发布会的主角K2和K2Pro正是 ...

  8. 对Hadoop体系的一点认识

    前言:Hadoop体系核心大多源自Google的思想,里面的思想的确很精彩!比如分布式计算,云的思想等,比起其他简单技术,更使得我想写这文章, 虽然这个东东在一般公司不可能用到! 首先由于hadoop ...

  9. [转载]Docker的安装配置及使用详解

    简介    官网:http://www.docker.com/,点击get started进入下载,目前三个系统的docker容器都有,Windows版需要win10系统,我的是win7系统一开始用的 ...

  10. spring 多线程 注入 服务层 问题

    在用多线程的时候,里面要用到Spring注入服务层,或者是逻辑层的时候,一般是注入不进去的.具体原因应该是线程启动时没有用到Spring实例不池.所以注入的变量值都为null. 详细:http://h ...