Educational Codeforces Round 39 G Almost Increasing Array
传送门
非减子序列 普通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相关推荐
- Educational Codeforces Round 25 G. Tree Queries
题目链接:Educational Codeforces Round 25 G. Tree Queries 题意: 给你一棵树,一开始所有的点全是黑色,有两种操作. 1 x 将x这个点变为黑色,保证第一 ...
- Educational Codeforces Round 32 G. Xor-MST 01tire + 分治 + Boruvka
传送门 文章目录 题意: 思路: 题意: 给你一个长度为nnn序列aaa,每两个点之间的边权为ai⊕aja_i\oplus a_jai⊕aj,问你最小生成树的权值是多少. n≤2e5,ai< ...
- 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 ...
- Educational Codeforces Round 39 B Weird Subtraction Process
传送门 模拟,写的比较土,别吐槽 #include <bits/stdc++.h> using namespace std; typedef long long ll ; typedef ...
- 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 ...
- Educational Codeforces Round 39 A Partition
传送门 分治就好了,哈哈大于小于0的数据分开算 #include <bits/stdc++.h> using namespace std; typedef long long ll ; t ...
- Educational Codeforces Round 21 G Anthem of Berland
题目链接 Berland has a long and glorious history. To increase awareness about it among younger citizens, ...
- Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...
- Educational Codeforces Round 32
http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...
最新文章
- react中高阶组件
- java ftl 标签_Freemarker-标签使用
- 单核工作法18:简化协作(下)
- PostgreSQL 并行查询概述
- iptables 学习笔记 二 参数指令
- 最大连续子数组和 动态规划_53. 最大子序和(动态规划)
- 告别码公式的痛苦,公式OCR终于来了!
- 《Java核心技术 卷12》读书笔记
- 先锋linux 64位安装包的安装使用
- 香橙派上手记录(orangepi pc)
- 推荐一个开源库(Calligraphy)将ttf字体库加入到项目中,轻松实现各种字体
- Tomcat执行startup.bat出现闪退的可能原因
- HTML插入一条竖线
- linux相关-ubuntu使用ssh public key登陆
- 学习笔记:李航统计学习方法
- Windows pytorch编译安装SoftPool
- LeetCode70. 爬楼梯(Java解法——使用完全背包求解)
- Java is Pass-by-Value, Dammit!
- 快手春节红包pk则么玩 快手拔河拼牛气活动规则介绍
- 自考07172信息安全历年真题 四套
热门文章
- VS2010新建Web网站与新建Web应用程序的区别
- pytorch中查看可训练参数
- [机器学习-原理篇]学习之线性回归、岭回归、Lasso回归
- leetcode —— 1282. 用户分组
- 吴恩达深度学习 —— 2.10 m个样本的梯度下降
- 计算机视觉基础——本质矩阵与基本矩阵(Essential and Fundamental Matrices)
- VC皮肤库SkinCrafter v3 4 0 0使用
- MySQL之User(用户)和Privilege(权限)
- 设计模式学习笔记——原型(Prototype)框架
- 百练 Let it Bead