HDU - 5256 序列变换 【LIS变形】
来源:互联网 发布:普通disco视频软件 编辑:程序博客网 时间:2024/05/20 16:33
传送们:5256
他让求至少可以改变几个数让他们单调递增
我们可以处理一下-.-让每一个数都减去i(这样在后面求出的最长递增子序列的每几个数之间都有相应的空位使他变过来)
然后求最长递增子序列就可以啦-.-
如:
4
2 3 3 4
变为
2 2 1 1
最长递增子序列为2,2 或1 ,1---
我们就可以变为2 3 4 5或1 2 3 4(变2个(4-2))
再如:
4
2 3 3 5
变为:
2 2 1 2
最长递增子序列为2 ,2,2
我们就把那个1也变为2--(变1个(4-3))
然后就是
2 2 2 2
还原为
2 3 4 5
代码:
#include<cstdio>#include<cstring>#include<algorithm> using namespace std;int a[100100],shu[100100],kp;void s(int xx){int n;scanf("%d",&n);for (int i=0;i<n;i++){scanf("%d",&shu[i]);shu[i]-=i;}kp=0;a[kp++]=shu[0];for (int i=1;i<n;i++)if (shu[i]>=a[kp-1])a[kp++]=shu[i];elsea[upper_bound(a,a+kp,shu[i])-a]=shu[i];printf("Case #%d:\n%d\n",xx,n-kp);}int main(){int t;scanf("%d",&t);for (int xx=1;xx<=t;xx++)s(xx);return 0;}
0 0
- hdu 5256 序列变换 (LIS变形)
- HDU - 5256 序列变换 【LIS变形】
- HDU 5256 序列变换 (LIS变形&&STL)
- HDU 5256 序列变换 (DP/LIS变形)
- hdoj--5256--序列变换(lis变形)
- hdoj 5256 序列变换 【LIS 变形】
- hdoj 5256 序列变换 (LIS变形)
- HDU-5256 序列变换(LIS)
- hdoj5256序列变换(LIS变形)
- HDU - 5256 序列变换 (LIS转化)
- 【HDU】5256 - 序列变换(LIS)
- HDU 5256 (序列变换 LIS)
- hdu 5256 LIS变形
- 【HDU】5256 序列变换(最长上升子序列变形)
- hdu 5256 序列变换 LIS 变型 思维转化
- hdu 5256 序列变换 -LIS 严格转非严格
- Problem 5256 序列变换 【LIS】
- HDU 4521小明序列(变形的LIS)
- 使用setvbuf更改printf的默认buffer 行为
- rpm安装mysql5.6
- Android中startActivityForResult竟然不起作用了....
- windows下动态库遇见的问题总结
- 在Ubuntu 12.04上安装LTIB及编译Linux BSP
- HDU - 5256 序列变换 【LIS变形】
- S重构重命名的快捷键
- http://www.cnblogs.com/chenlulouis/archive/2010/07/07/1772631.html
- jdbc oracle数据库访问
- 位段和联合
- 博弈论专题——推理与动态规划相关博弈之POJ2348
- 大话设计模式学习笔记---依赖倒转原则
- HDU 2112 HDU Today
- 10.shell编程(10) --- 函数(2)