最长非递减子序列变形题,把大于等于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. python matplotlib(数据可视化)

    吐槽 网上搜了不少matplotlib安装方法(不信,你可以试试.) 我只能说,除了太繁琐,就是没什么用! 如果你是python3.6.5版本 我给你最最最正确的建议: 直接打开cmd,找到pip用命 ...

  2. keras Model 1 入门篇

    1 入门 2 多个输入和输出 3 共享层 最近在学习keras,它有一些实现好的特征提取的模型:resNet.vgg.而且是带权重的.用来做特诊提取比较方便 首先要知道keras有两种定义模型的方式: ...

  3. Docs-.NET-C#-指南-语言参考-预处理器指令:#undef(C# 参考)

    ylbtech-Docs-.NET-C#-指南-语言参考-预处理器指令:#undef(C# 参考) 1.返回顶部 1. #undef(C# 参考) 2018/06/30 #undef 允许你定义一个符 ...

  4. 【React自制全家桶】一、Webstrom+React+Ant Design+echarts搭建react项目

    前言 一.React是Facebook推出的一个前端框架,之前被用于著名的社交媒体Instagram中,后来由于取得了不错的反响,于是Facebook决定将其开源.出身名门的React也不负众望,成功 ...

  5. Oracle 11g 监听很慢,由于监听日志文件太大引起的问题(Windows 下)

    现象:Windows 操作系统的Oracle 数据库,使用sqlplus 连接(不指定实例名)连接很快,程序连接或使用连接工具或在Net Manager 中测试连接都需要花费约三四十秒的时间(程序连接 ...

  6. QML之信号与槽

    一.C++的信号和QML的槽 前言: Qt中的信号与槽,通常是一个信号SIGNAL和一个槽SLOT,通过connet连接,而QML中不需要再写槽函数,只需要在合适的地方告诉QML:如果x信号产生则执行 ...

  7. Linux -- PHP-FPM的源码解析和模型

    1.进程管理模式 PHP-FPM由1个master进程和N个worker进程组成.其中,Worker进程由master进程fork而来. PHP-FPM有3种worker进程管理模式. 1. Stat ...

  8. 【406】C语言相关函数

    <stdlib.h>(1) <stdlib.h>(2) malloc() 用来动态地分配内存空间,分配成功返回指向该内存的地址,失败则返回 NULL. 前面的 (int*) 或 ...

  9. python中的列表推导式——轻量级循环

    列表推导式(list comprehension)是利用其他列表创建新列表(类似于数学术语中的集合推导式)的一种方法.它的工作方式类似于for循环,也很简单. 列表推导式书写形式: [表达式 for ...

  10. PAT 甲级 1055 The World's Richest (25 分)(简单题,要用printf和scanf,否则超时,string 的输入输出要注意)

    1055 The World's Richest (25 分)   Forbes magazine publishes every year its list of billionaires base ...