最长非递减子序列变形题,把大于等于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. node.js 简易聊天室

    效果图 首先开启server.js 打开服务器端,然后打开client.js,注册用户.打开一个注册一个用户,打开三个,注册三个用户. 接下来,小王发布一个广播消息,小李和小刘都收到了此消息. 接下来 ...

  2. 小福bbs—项目系统设计与数据库设计

    这个作业属于哪个课程 班级链接 这个作业要求在哪里 作业要求的链接 团队名称 小福bbs 这个作业的目标 实现对校园论坛软件的制作,使其能够发布帖子,查看信息等 作业的正文 小福bbs--项目需求分析 ...

  3. case设计及验证:入口+页面+展示

    测试个性CB问题, 功能整体结构为:入口+页面+展示 总结: 1. 产品文档为主,其次是服务端接口返回.数据结构及字段值确认.结合实际场景检查是否有遗漏或不合理. 2. 以字段为维度,每个字段的检查点 ...

  4. vsCode中如何根据屏幕宽度自动换行

      在设置中搜索editor.wordWrap   文章来源:外星人来地球 欢迎关注,有问题一起学习欢迎留言.评论

  5. 【Python】把文件名命名成canlendar.py竟然导致无法使用canlendar模块 附赠2020年月历

    这个bug困扰了我一阵,直到在 http://www.codingke.com/question/15489 找到了解决问题的钥匙,真是没想到居然是这个原因导致的. 下面是出错信息,可以看到只要目录下 ...

  6. 【分类算法】朴素贝叶斯(Naive Bayes)

    0 - 算法 给定如下数据集 $$T=\{(x_1,y_1),(x_2,y_2),\cdots,(x_N,y_N)\},$$ 假设$X$有$J$维特征,且各维特征是独立分布的,$Y$有$K$种取值.则 ...

  7. 123457123456#0#-----com.twoapp.jingPinYinYu01----儿童学英语jiemei

    com.twoapp.jingPinYinYu01----儿童学英语jiemei

  8. iOS compile sources问题

    以前xcode compile sources 这里是自动生成的,升级到新版本之后,我删掉这里的列表,就没法生成了.导致项目无法运行. 解决方法就是:自己手动添加.h文件

  9. html页面js响应回车

    代码示例: document.onkeydown=function(event){ var e = event || window.event || arguments.callee.caller.a ...

  10. Tinymce在ASP.NET中的使用方法

    现在做网页,用FCKEditor用得比较多,它的实现原理是在要加入FCKEditor的地方加入一个iframe,并将其src指向FCKeditor/editor/fckeditor.html?Inst ...