Removed Interval HDU
来源:互联网 发布:证券软件下载 编辑:程序博客网 时间:2024/06/05 03:36
问一个n元序列任删掉一段m长的子段后的LIS长度
n1e5,考虑枚举剩下的右端点参与答案贡献,我们需要右端点开始的LIS,以及删除段左边的,刚好比右端点小的点往前跑的LIS
前者可以去个负倒过来跑一下,后者双针边跑边更新就行
//#include<bits/stdc++.h> //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<stdio.h> #include<algorithm> #include<queue> #include<string.h> #include<iostream> #include<math.h> #include<set> #include<map> #include<vector> #include<iomanip> using namespace std; const double pi=acos(-1.0); #define ll long long #define pb push_back#define sqr(a) ((a)*(a))#define dis(a,b) sqrt(sqr(a.x-b.x)+sqr(a.y-b.y))#define FOR(a) for(int i=1;i<=a;i++)const double eps=1e-10;const int maxn=1e5+56;const int inf=0x3f3f3f3f;int a[maxn],b[maxn],dp[maxn],f[maxn];int main(){int T;scanf("%d",&T);int kase=0;while(T--){int n,m;scanf("%d%d",&n,&m);for(int i=1;i<=n;i++){scanf("%d",&a[i]);b[i]=-a[i];}memset(dp,0x3f,sizeof dp);for(int i=n;i>=1;i--){int t=lower_bound(dp+1,dp+1+n,b[i])-dp;f[i]=t;//i开头的最长长度dp[t]=b[i];}memset(dp,0x3f,sizeof dp);int ans=0;for(int i=m+1;i<=n;i++){//枚举右端点int t=lower_bound(dp+1,dp+1+n,a[i])-dp;ans=max(ans,t-1+f[i]);*lower_bound(dp+1,dp+1+n,a[i-m])=a[i-m];}//在求左边lis过程中找右端点的lbint t=lower_bound(dp+1,dp+1+n,inf)-dp;//全左ans=max(ans,t-1);printf("Case #%d: %d\n",++kase,ans);}}
阅读全文
0 0
- hdu 5489 Removed Interval
- Removed Interval HDU
- [HDU 5489]Removed Interval[LIS]
- hdu 5489 Removed Interval LIS变形
- HDU 5489 Removed Interval (LIS,变形)
- hdu 5489 Removed Interval lis变形
- HDU 5489 Removed Interval(DP)
- Hdu 5489 Removed Interval【LIS+线段树】
- HDU 5489 Removed Interval (合肥网络赛 1006 )
- hdu 5489 Removed Interval(线段树+LIS)
- hdu 5489 Removed Interval 动态规划,最长上升子序列
- hdu5489 Removed Interval
- HDU5489 Removed Interval LIS
- hdu5489 Removed Interval LIS
- hdu5489 Removed Interval
- hdu5489 Removed Interval
- HDU 5489 Removed Interval (dp+线段树) 2015合肥网络赛
- HDU 5489 Removed Interval(2015合肥站网赛1006,DP+树状数组)
- [UVA 122] Trees on the level 二叉树好难+BFS
- java的volatile关键字之非线程安全
- Add two numbers
- PTA 7-22(排序) 模拟EXCEL排序(25 分)25分代码 结构体排序
- Linux 基础操作(七)————系统服务的控制
- Removed Interval HDU
- (四)系统虚拟化关键技术
- 设备树详解(链接很好,作者嵌入式Linux见解深刻)
- android基本架构
- js数据类型笔记
- Wannafly模拟赛3-B 贝伦卡斯泰露(DFS)
- JVM调优总结(3):垃圾回收面临的问题
- IPC(进程间通信)-基本概念
- Lua中元表Metatables与元方法Metamethods