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 ...
随机推荐
- sdut2784&cf 126b Good Luck!(next数组)
链接 next数组的巧妙应用 学弟出给学弟的学弟的题.. 求最长的 是前缀也是后缀同时也是中缀的串 next的数组求的就是最长的前后缀 但是却不能求得中缀 所以这里 就把尾部去掉之后再求 这样就可 ...
- SpringBoot之旅第七篇-Docker
一.引言 记得上大三时,要给微机房电脑安装系统,除了原生的操作系统外,还要另外安装一些必要的开发软件,如果每台电脑都重新去安装的话工作量就很大了,这个时候就使用了windows镜像系统,我们将要安装的 ...
- R in action读书笔记(16)第十二章 重抽样与自助法之 置换检验
第十二章:重抽样与自助法 本章,我们将探究两种应用广泛的依据随机化思想的统计方法:置换检验和自助法 12.1 置换检验 置换检验,也称随机化检验或重随机化检验. 有两种处理条件的实验,十个受试者已经被 ...
- 手动将Excel数据导入SQL
1. 右键点击数据库名称,Tasks --> Import Data... 2. Choose Data Source:MicroSoft Excel,选择Excel文件和Excel版本.Exc ...
- SQL Server性能调优——报表数据库与业务数据库分离
前段时间把公司的主数据库切了,分成业务库和报表库,业务库向报表库进行实时的Replication.这个项目的上线提升了系统的性能和可维护性,现在把设计时的考量和所做的工作重新回顾一下,作为备忘. 项目 ...
- 【PostgreSQL-9.6.3】启动,登录,退出,关闭
当我们费尽千辛万苦安装完数据库后,一定会迫不及待的想使用它.骚年,不要着急,且看我为您解析PostgreSQL的启动,登录,退出,关闭过程. 一 启动数据库服务器 1. 没有设置环境变量的情况下 po ...
- 一些常用的meta标签及其作用
声明文档使用的字符编码 <meta charset='utf-8'>优先使用 IE 最新版本和 Chrome <meta http-equiv="X-UA-Compat ...
- zabbix3.0.4 部署之八 (zabbix3.0.4 报警前端配置)
(如何让报警信息推送----微信.邮件)(邮件与微信一样就不在重复) 创建一个用户 将用户加入administrator组 添加之前设置的报警媒介脚本 设置报警等级 创建动作 配置报警内容 设置报警条 ...
- 合并百度影音的离线数据 with python 第二版 基于yield
重新整理了一下代码. 增加了bdv,mkv的处理流程. 目前暂时支持windows平台. bdv,mkv,rmvb的不同处理流程 # -*- coding: UTF-8 -*- import os i ...
- Codeforces_791_B. Bear and Friendship Condition_(dfs)
B. Bear and Friendship Condition time limit per test 1 second memory limit per test 256 megabytes in ...