传送门

非减子序列 普通lcs Dp TLE ,换成upper_bound 竟然过了,神奇

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef double    dl ;
#define INF ((ll)2e9)const int  inf = 987654321;
const int sz = 1e6 + 5;
const int mod = 1e9 + 7;
const int sqrtn = 300;#define f(i,l,r) for(int i=l;i<=r;++i)
#define g(i,l,r) for(int i=l;i>=r;--i)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define sz(a)   strlen(a)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);#define lowbit(x) x&(-x)
#define X first
#define Y second #define pb push_back
#define pii pair<int,int>int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};void work1()
{int seq1[] = {1, 2, 3, 3, 4, 5}, seq2[] = {9, 8, 7, 7, 6, 5};cout<<upper_bound(seq1, seq1+6, 3) - seq1<<endl;cout<<lower_bound(seq1, seq1+6, 3) - seq1<<endl;cout<<endl;cout<<upper_bound(seq2, seq2+6, 7, greater<int>()) - seq2<<endl;cout<<lower_bound(seq2, seq2+6, 7, greater<int>()) - seq2<<endl;
}
ll n,dp[2][sz];
ll ans,x;
void work()
{cin>>n;f(i,0,sz-1)dp[0][i]=dp[1][i]=INF;dp[0][0]=-INF;ll change =0;f(i,1,n){cin>>x;ll id = upper_bound(dp[1],dp[1]+sz,x-i+1)-dp[1];dp[1][id]=x-i+1;ans=max(ans,id);dp[1][change]=min(dp[0][change],dp[1][change]);ans=max(ans,change);id = upper_bound(dp[0],dp[0]+sz,x-i)-dp[0];change=id;dp[0][id]=x-i; }cout<<n-ans-1<<"\n";
}int main()
{FAST_IO ;freopen("in","r",stdin);freopen("out","w",stdout);cout<<"hello"<<endl;work3();return 0;
}

转载于:https://www.cnblogs.com/corx/p/8523892.html

Educational Codeforces Round 39 G Almost Increasing Array相关推荐

  1. Educational Codeforces Round 25 G. Tree Queries

    题目链接:Educational Codeforces Round 25 G. Tree Queries 题意: 给你一棵树,一开始所有的点全是黑色,有两种操作. 1 x 将x这个点变为黑色,保证第一 ...

  2. Educational Codeforces Round 32 G. Xor-MST 01tire + 分治 + Boruvka

    传送门 文章目录 题意: 思路: 题意: 给你一个长度为nnn序列aaa,每两个点之间的边权为ai⊕aja_i\oplus a_jai​⊕aj​,问你最小生成树的权值是多少. n≤2e5,ai< ...

  3. Educational Codeforces Round 37 G. List Of Integers (二分,容斥定律,数论)

    G. List Of Integers time limit per test 5 seconds memory limit per test 256 megabytes input standard ...

  4. Educational Codeforces Round 39 B Weird Subtraction Process

    传送门 模拟,写的比较土,别吐槽 #include <bits/stdc++.h> using namespace std; typedef long long ll ; typedef ...

  5. Educational Codeforces Round 39 F Largest Beautiful Number

    传送门 暴力DP dp[i][j][k] 从j 到 k 发f(x) 的大小, #include <bits/stdc++.h> using namespace std; typedef l ...

  6. Educational Codeforces Round 39 A Partition

    传送门 分治就好了,哈哈大于小于0的数据分开算 #include <bits/stdc++.h> using namespace std; typedef long long ll ; t ...

  7. Educational Codeforces Round 21 G Anthem of Berland

    题目链接 Berland has a long and glorious history. To increase awareness about it among younger citizens, ...

  8. Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...

  9. Educational Codeforces Round 32

    http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...

最新文章

  1. react中高阶组件
  2. java ftl 标签_Freemarker-标签使用
  3. 单核工作法18:简化协作(下)
  4. PostgreSQL 并行查询概述
  5. iptables 学习笔记 二 参数指令
  6. 最大连续子数组和 动态规划_53. 最大子序和(动态规划)
  7. 告别码公式的痛苦,公式OCR终于来了!
  8. 《Java核心技术 卷12》读书笔记
  9. 先锋linux 64位安装包的安装使用
  10. 香橙派上手记录(orangepi pc)
  11. 推荐一个开源库(Calligraphy)将ttf字体库加入到项目中,轻松实现各种字体
  12. Tomcat执行startup.bat出现闪退的可能原因
  13. HTML插入一条竖线
  14. linux相关-ubuntu使用ssh public key登陆
  15. 学习笔记:李航统计学习方法
  16. Windows pytorch编译安装SoftPool
  17. LeetCode70. 爬楼梯(Java解法——使用完全背包求解)
  18. Java is Pass-by-Value, Dammit!
  19. 快手春节红包pk则么玩 快手拔河拼牛气活动规则介绍
  20. 自考07172信息安全历年真题 四套

热门文章

  1. VS2010新建Web网站与新建Web应用程序的区别
  2. pytorch中查看可训练参数
  3. [机器学习-原理篇]学习之线性回归、岭回归、Lasso回归
  4. leetcode —— 1282. 用户分组
  5. 吴恩达深度学习 —— 2.10 m个样本的梯度下降
  6. 计算机视觉基础——本质矩阵与基本矩阵(Essential and Fundamental Matrices)
  7. VC皮肤库SkinCrafter v3 4 0 0使用
  8. MySQL之User(用户)和Privilege(权限)
  9. 设计模式学习笔记——原型(Prototype)框架
  10. 百练 Let it Bead