最长非递减子序列变形题,把大于等于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. contos的apt-get安装

    本文链接:https://blog.csdn.net/lesz_s/article/details/88732500 首先contos的软件包管理是yum但是yum包好多都没有 比如我想装的slwge ...

  2. Microsoft Visual C++ Runtime library not enough space for thread data

    Microsoft Visual C++ Runtime library not enough space for thread data     电脑最近一直在运行的时候,弹出提示框,如下: 解决办 ...

  3. JS 将页面上的表格导出为 Excel 文件

    如果在页面上展示了一个表格,想把这个表格导出为Excel文件,那么在要求不高的情况下,可以直接利用 JavaScript 的 Blob 和 Object URL 特性将表格导出.不过,这就是利用了 E ...

  4. SQL-W3School-总结:SQL 总结

    ylbtech-SQL-W3School-总结:SQL 总结 1.返回顶部 1. SQL 概要 本教程已经向您讲解了用来访问和处理数据库系统的标准计算机语言. 我们已经学习了如何使用 SQL 在数据库 ...

  5. 深入理解DefaultMessageListenerContainer

    DefaultMessageListenerContainer是一个用于异步消息监听的管理类. DefaultMessageListenerContainer最简单的实现逻辑,一个任务执行器,执行任务 ...

  6. python定义接口继承类

    zxq547 python定义接口继承类invalid syntax解决办法 1 2 3 4 5 6 7 class s_all(metaclass=abc.ABCMeta):     #python ...

  7. Java高并发程序设计

    一.并行世界 摩尔定律的失效,2004年秋季,Intel宣布彻底取消4GHz计划,CPU向多核心的发展,顶级计算机科学家唐纳德丶尔文丶克努斯评价:在我看来,这种现象(并发)或多或少是由于硬件设计者已经 ...

  8. python数据可视化:pyecharts

    发现了一个做数据可视化非常好的库:pyecharts.非常便捷好用,大力推荐!! 官方介绍:pyecharts 是一个用于生成 Echarts 图表的类库.Echarts 是百度开源的一个数据可视化 ...

  9. react ant design TreeNode——树形菜单笔记

     2017-12-04补充说明——树形菜单版本号2.x 设置默认该树形组件展开(默认展开所有树节点) 参考文档的写法: defaultExpandAll={true} //经过测试并不生效, 另外注意 ...

  10. 【C# 开发技巧】番外篇故事-我是一个线程

    我是一个线程 我是一个线程,一出生就被编了一个号——0x3704,然后被领到一间昏暗的屋子里,在这里,我发现了很多和我一模一样的同伴.我身边的同伴0x6900待的时间比较长,他带着沧桑的口气对我说:“ ...