BZOJ4990&&BZOJ4993(Usaco2017 Feb)[Why Did the Cow Cross the Road II]--最长升
来源:互联网 发布:华师大公共数据库密码 编辑:程序博客网 时间:2024/06/05 16:52
【链接】
bzoj4990
bzoj4993
【解题报告】
最长公共子序列转最长升。
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=1000005;int n,m,ans,a[maxn],que[maxn];int Abs(int x) {if (x<0) return (-x); return x;}int Find(int x){ int L=1,R=n; while (L<=R) { int mid=(R-L>>1)+L; if (x>que[mid]) L=mid+1; else R=mid-1; } return R;}int main(){ freopen("4990.in","r",stdin); freopen("4990.out","w",stdout); scanf("%d",&n); m=ans=0; for (int i=1,x; i<=n; i++) scanf("%d",&x),a[x]=i; memset(que,63,sizeof(que)); for (int i=1; i<=n; i++) { int x,c[10],cnt=0; scanf("%d",&x); for (int k=-4; k<=4; k++) if (x+k>=1&&x+k<=n) c[++cnt]=a[x+k]; sort(c+1,c+1+cnt); for (int j=cnt; j; j--) { x=Find(c[j]); que[x+1]=c[j]; if (x+1>ans) ans=x+1; } } printf("%d",ans); return 0;}
阅读全文
0 0
- BZOJ4990&&BZOJ4993(Usaco2017 Feb)[Why Did the Cow Cross the Road II]--最长升
- bzoj4993 [Usaco2017 Feb]Why Did the Cow Cross the Road II
- bzoj4993: [Usaco2017 Feb]Why Did the Cow Cross the Road II
- bzoj4990 [Usaco2017 Feb]Why Did the Cow Cross the Road II(dp+树状数组)
- 【bzoj4990】[Usaco2017 Feb]Why Did the Cow Cross the Road II
- [Usaco2017 Feb]Why Did the Cow Cross the Road II
- 4992: [Usaco2017 Feb]Why Did the Cow Cross the Road
- bzoj4995: [Usaco2017 Feb]Why Did the Cow Cross the Road
- bzoj4989: [Usaco2017 Feb]Why Did the Cow Cross the Road
- Bzoj4989 [Usaco2017 Feb]Why Did the Cow Cross the Road
- [Usaco2017 Feb]Why Did the Cow Cross the Road
- [Usaco2017 Feb]Why Did the Cow Cross the Road III
- bzoj 4993: [Usaco2017 Feb]Why Did the Cow Cross the Road II
- BZOJ 4993: [Usaco2017 Feb]Why Did the Cow Cross the Road II LCS
- BZOJ 4990: [Usaco2017 Feb]Why Did the Cow Cross the Road II 树状数组优化LCS
- bzoj 4990: [Usaco2017 Feb]Why Did the Cow Cross the Road II
- 4990: [Usaco2017 Feb]Why Did the Cow Cross the Road II
- bzoj4996: [Usaco2017 Feb]Why Did the Cow Cross the Road II
- 数组中只出现一次的两个数(异或)
- pygame库写游戏——入门<1>
- 奇异值分解(SVD)原理
- okhttp公共参数拦截器
- 经典导弹拦截dp问题(n^2算法)FZOJ 1570
- BZOJ4990&&BZOJ4993(Usaco2017 Feb)[Why Did the Cow Cross the Road II]--最长升
- 栈&栈的应用
- 快速求素数表——埃氏筛法与欧拉筛法
- CSS3-转换之skew
- Unity的特殊文件夹及脚本编译顺序
- java--归并排序
- NLTK频率分类种定义的函数
- 基于LU分解的矩阵求逆
- ADV-162-最大最小值