xtu summer individual 5 D - Subsequence
Subsequence
This problem will be judged on HDU. Original ID: 3530
64-bit integer IO format: %I64d Java class name: Main
Input
For each test case, the first line has three integers, n, m and k. n is the length of the sequence and is in the range [1, 100000]. m and k are in the range [0, 1000000]. The second line has n integers, which are all in the range [0, 1000000].
Proceed to the end of file.
Output
Sample Input
5 0 0
1 1 1 1 1
5 0 3
1 2 3 4 5
Sample Output
5
4
Source
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = ;
int qa[maxn],qb[maxn],h1,h2,t1,t2;
int n,m,k,d[maxn],lst1,lst2;
int main(){
int i,ans;
while(~scanf("%d %d %d",&n,&m,&k)){
for(i = ; i <= n; i++)
scanf("%d",d+i);
lst2 = lst1 = h1 = h2 = ;
t1 = t2 = -;
ans = ;
for(i = ; i <= n; i++){
while(t1 >= h1 && d[qa[t1]] <= d[i]) t1--;
qa[++t1] = i;
while(t2 >= h2 && d[qb[t2]] >= d[i]) t2--;
qb[++t2] = i;
while(d[qa[h1]] - d[qb[h2]] > k){
if(qa[h1] < qb[h2]){
lst1 = qa[h1++];
}else lst2 = qb[h2++];
}
if(d[qa[h1]] - d[qb[h2]] >= m)
ans = max(ans,i-max(lst1,lst2));
}
printf("%d\n",ans);
}
return ;
}
/*
5 0 0
1 1 1 1 1
5 0 3
1 2 3 4 5
*/
xtu summer individual 5 D - Subsequence的更多相关文章
- xtu summer individual 4 C - Dancing Lessons
Dancing Lessons Time Limit: 5000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...
- xtu summer individual 3 C.Infinite Maze
B. Infinite Maze time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- xtu summer individual 2 E - Double Profiles
Double Profiles Time Limit: 3000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...
- xtu summer individual 2 C - Hometask
Hometask Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Origin ...
- xtu summer individual 1 A - An interesting mobile game
An interesting mobile game Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on H ...
- xtu summer individual 2 D - Colliders
Colliders Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Origi ...
- xtu summer individual 1 C - Design the city
C - Design the city Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu D ...
- xtu summer individual 1 E - Palindromic Numbers
E - Palindromic Numbers Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %l ...
- xtu summer individual 1 D - Round Numbers
D - Round Numbers Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u D ...
随机推荐
- Neighbor House LightOJ - 1047
Neighbor House LightOJ - 1047 #include<cstdio> #include<cstring> #include<algorithm&g ...
- C#---数据库访问通用类、Access数据库操作类、mysql类 .[转]
原文链接 //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using Sy ...
- 动态添加出来append的元素加事件
$("body").on("click","#box span",function(){里面执行的东西}) span 是动态添加出来的
- 不重启IIS修改dotnet framework版本
因为公司现在存在.net站点和asp站点共同运行的情况,所以需要对IIS进行一些修改,运行环境Win2003+IIS6 一.起因 原来的老站是asp开发的,用的是.net 2.0运行环境; 新站是.n ...
- 关于.Net中Process的使用方法和各种用途汇总(二):用Process启动cmd.exe完成将cs编译成dll
上一章博客我为大家介绍了Process类的所有基本使用方法,这一章博客我来为大家做一个小扩展,来熟悉一下Process类的实际使用,废话不多说我们开始演示. 先看看我们的软件要设计成的布局吧. 首先我 ...
- PHP PDO事务处理及MYSQLengine=InnoDB
如果出现“#skip-innodb”则将“#”去掉,重启MySQL: 如果第一条无法解决,加上配置:default-storage-engine=InnoDB 再重启MySQL. 进入MYsql数据据 ...
- spark shuffle参数及调优建议(转)
原文:http://www.cnblogs.com/arachis/p/Spark_Shuffle.html spark.shuffle.file.buffer 默认值:32k 参数说明:该参数用于设 ...
- iOS-UI控件之UIImageView
contentMode属性 带有scale单词的:图片有可能会拉伸 UIViewContentModeScaleToFill 将图片拉伸至填充整个imageView 图片显示的尺寸跟imageView ...
- 一台机器运行多个JBoss多实例
JBossXMLJVMTomcat应用服务器 我们经常会遇到这种情况,有时候希望在同一台机器上部署若干个JBoss实例,上面运行不同的应用程序,这样的话无论由于什么原因需要对某个JBoss实例进行关 ...
- JVM参数说明介绍
1.JVM运行时数据区内存参数说明 2.JVM垃圾收集器参数总结 原文:https://blog.csdn.net/bluuusea/article/details/90697340 ======== ...