最长非递减子序列变形题,把大于等于10000的copy五次放回去就可以了

ac代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define LL long long
const LL N=;
int a[N];
int dp[N];
int LIS(int a[],int len)
{
int dlen=;
memset(dp,,sizeof(dp));
dp[]=a[];//
for(int i=;i<len;i++)
{
if(a[i] < dp[]) // 最开始的位置
{
dp[]=a[i];
continue;
}
if(a[i] >= dp[dlen-])
{
dp[dlen++]=a[i];// new insert
}
else
{
int pos=upper_bound(dp,dp+dlen,a[i])-dp;//
dp[pos]=a[i];
}
}
return dlen;
}
int main()
{
int len=;
int x;
while(~scanf("%d",&x))
{
if(x<) continue;
if(x>=)
{
x-=;
for(int i=;i<=;i++) a[len++]=x;
}
else a[len++]=x;
}
/*
for(int i=1;i<=14;i++)
{
scanf("%d",&x);
if(x<0) continue;
if(x>=10000)
{
x-=10000;
for(int i=1;i<=5;i++) a[len++]=x;
}
else a[len++]=x;
}
*/
// for(int i=1;i<=len;i++) cout<<a[i]<<' ';
// cout<<endl;
cout<<LIS(a,len)<<endl;
return ;
}

The Heaviest Non-decreasing Subsequence Problem的更多相关文章

  1. SPOJ LIS2 Another Longest Increasing Subsequence Problem 三维偏序最长链 CDQ分治

    Another Longest Increasing Subsequence Problem Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://a ...

  2. SPOJ Another Longest Increasing Subsequence Problem 三维最长链

    SPOJ Another Longest Increasing Subsequence Problem 传送门:https://www.spoj.com/problems/LIS2/en/ 题意: 给 ...

  3. 2017ICPC南宁赛区网络赛 The Heaviest Non-decreasing Subsequence Problem (最长不下降子序列)

    Let SSS be a sequence of integers s1s_{1}s​1​​, s2s_{2}s​2​​, ........., sns_{n}s​n​​ Each integer i ...

  4. 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem

    Let SS be a sequence of integers s_{1}s​1​​, s_{2}s​2​​, ......, s_{n}s​n​​Each integer is is associ ...

  5. 2017 ACM/ICPC Asia 南宁区 L The Heaviest Non-decreasing Subsequence Problem

    2017-09-24 20:15:22 writer:pprp 题目链接:https://nanti.jisuanke.com/t/17319 题意:给你一串数,给你一个处理方法,确定出这串数的权值, ...

  6. [Algorithms] Using Dynamic Programming to Solve longest common subsequence problem

    Let's say we have two strings: str1 = 'ACDEB' str2 = 'AEBC' We need to find the longest common subse ...

  7. SPOJ:Another Longest Increasing Subsequence Problem(CDQ分治求三维偏序)

    Given a sequence of N pairs of integers, find the length of the longest increasing subsequence of it ...

  8. SPOJ - LIS2 Another Longest Increasing Subsequence Problem

    cdq分治,dp(i)表示以i为结尾的最长LIS,那么dp的递推是依赖于左边的. 因此在分治的时候需要利用左边的子问题来递推右边. (345ms? 区间树TLE /****************** ...

  9. SPOJ LIS2 - Another Longest Increasing Subsequence Problem(CDQ分治优化DP)

    题目链接  LIS2 经典的三维偏序问题. 考虑$cdq$分治. 不过这题的顺序应该是 $cdq(l, mid)$ $solve(l, r)$ $cdq(mid+1, r)$ 因为有个$DP$. #i ...

随机推荐

  1. firewall-cmd命令详解

    https://blog.csdn.net/GMingZhou/article/details/78090963 实例 # 安装firewalld yum install firewalld fire ...

  2. 用vs2017对C#代码进行单元测试

    1.打开vs2017->工具->扩展与更新->联机 进行搜索Unit,截图如下: 创建C#项目: 将测试代码复制到里边,这里用到的是老师课上给的实验代码: public class ...

  3. mysql 实现同一个sql查询 分页数据 和总记录数

    $get_sql = "SELECT sql_calc_found_rows field1,field2 FROM table WHERE name = '1' order by add_t ...

  4. 超详细Qt5.9.5移植攻略

    本文就来介绍下如何将Qt5.9.5移植到ARM开发板上. 以imx6开发板为例,使用Ubuntu14.04虚拟机作为移植环境. 准备工作 1.主机环境:Ubuntu14.04: 开发板:启扬IAC-I ...

  5. mac、windows、linux版jdk1.8下载

    链接: https://pan.baidu.com/s/1Yjs6GIxURiocq30zZ7heYQ 提取码: g6i8

  6. PHP网络服务

    [Socket] socket_create 用于创建一个Socket socket_bind 用于将IP地址和端口绑定到socket_create 函数所创建的句柄中. socket_listen ...

  7. SQL-W3School-高级:SQL 数据库

    ylbtech-SQL-W3School-高级:SQL 数据库 1.返回顶部 1. 现代的 SQL 服务器构建在 RDBMS 之上. DBMS - 数据库管理系统(Database Managemen ...

  8. Error setting null for parameter #10 with JdbcType

    转: Error setting null for parameter #10 with JdbcType OTHER . 2014年02月23日 11:00:33 厚积 阅读数 58535   my ...

  9. linux修改配置文件解决mysql中文乱码和指定数据库存储引擎

    如题,mysql数据库的中文显示乱码: 先看下原来数据库里的字符编码: mysql> show variables like '%character_set%'; +-------------- ...

  10. javascript——语法 && 结构

    原文链接:Understanding Syntax and Code Structure