E. Exposition
time limit per test

2 seconds

memory limit per test

64 megabytes

input

standard input

output

standard output

There are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection the local library decided to make an exposition of the works of this famous science-fiction writer. It was decided as well that it is necessary to include into the exposition only those books that were published during a particular time period. It is obvious that if the books differ much in size, the visitors will not like it. That was why the organizers came to the opinion, that the difference between the highest and the lowest books in the exposition should be not more than k millimeters.

The library has n volumes of books by Berlbury, arranged in chronological order of their appearance. The height of each book in millimeters is know, it is hi. As Berlbury is highly respected in the city, the organizers want to include into the exposition as many books as possible, and to find out what periods of his creative work they will manage to cover. You are asked to help the organizers cope with this hard task.

Input

The first line of the input data contains two integer numbers separated by a space n (1 ≤ n ≤ 105) and k (0 ≤ k ≤ 106) — the amount of books by Berlbury in the library, and the maximum allowed height difference between the lowest and the highest books. The second line contains n integer numbers separated by a space. Each number hi (1 ≤ hi ≤ 106) is the height of the i-th book in millimeters.

Output

In the first line of the output data print two numbers a and b (separate them by a space), where a is the maximum amount of books the organizers can include into the exposition, and b — the amount of the time periods, during which Berlbury published a books, and the height difference between the lowest and the highest among these books is not more than k milllimeters.

In each of the following b lines print two integer numbers separated by a space — indexes of the first and the last volumes from each of the required time periods of Berlbury's creative work.

Sample test(s)
input
3 3
14 12 10
output
2 2
1 2
2 3
input
2 0
10 10
output
2 1
1 2
input
4 5
8 19 10 13
output
2 1
3 4
 #include <iostream>
#include <stdio.h>
#include <set>
using namespace std;
int a[],c[];
int main()
{
int n,k,i,b=,max=,p=;
scanf("%d%d",&n,&k);
multiset<int> z;
for(i=; i<n; i++)
{
scanf("%d",&a[i]);
z.insert(a[i]);
while(*z.rbegin()-*z.begin()>k)z.erase(z.find(a[b++]));
if(i-b+>max)
{
max=i-b+,p=;c[p++]=b;
}
else if(i-b+==max)
{
c[p++]=b;
}
}
cout<<max<<" "<<p<<endl;
for(i=; i<p; i++)
printf("%d %d\n",c[i]+,c[i]+max);
}

E. Exposition的更多相关文章

  1. Codeforces Beta Round #6 (Div. 2 Only) E. Exposition multiset

    E. Exposition Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/ ...

  2. A - Exposition CodeForces - 6E

    题目链接:https://vjudge.net/contest/202699#problem/A 题意 给一个n个元素的序列,从中挑出最长的子序列,要求子序列中元素差的最大值不超过k.问有几个最长子序 ...

  3. Codeforces - 6E - Exposition - 尺取

    https://codeforc.es/problemset/problem/6/E 既然可以多个log,那就直接map伺候.尺取之后要查询区间里面的最大值和最小值的差.众所周知尺取的时候要是不是有序 ...

  4. ECMAScript 6 Features 中文版

    ECMAScript 6 Features 中文版 如词不达意,欢迎提 PR & issue 采用中英混排的方式进行译制,如不解请查看对应原文 本文档将与原作者的 文档 保持同步更新,欢迎关注 ...

  5. Back-propagation, an introduction

    About Contact Subscribe   Back-propagation, an introduction Sanjeev Arora and Tengyu Ma  •  Dec 20, ...

  6. 【转】关于KDD Cup '99 数据集的警告,希望从事相关工作的伙伴注意

    Features From: Terry Brugger Date: 15 Sep 2007 Subject: KDD Cup '99 dataset (Network Intrusion) cons ...

  7. boost(barrier)

    barrier:栅栏的意思,当barrier bar(3),这三个线程会放到栅栏中,等第三个线程执行时一起唤醒,然后返回 barrier barrier类的接口定义如下: class barrier ...

  8. Hacker's guide to Neural Networks

    Hacker's guide to Neural Networks Hi there, I'm a CS PhD student at Stanford. I've worked on Deep Le ...

  9. PyOpenGL利用文泉驿正黑字体显示中文字体

    摘要:在NeHe的OpenGL教程第43课源代码基础上,调用文泉驿正黑字体实现中文字体的显示 在OpenGL中显示汉字一直是个麻烦的事情,很多中文书籍的文抄公乐此不疲地介绍各种方法及其在windows ...

随机推荐

  1. 支付宝小程序PHP全栈开发--前端样式的设计.acss样式详解

    关于.acss文件 在视频中已经说过了,小程序的设计思想和原生app的设计思想颇为相似,基本的应用单元为页面.当然对于一个页面来说每一个元素的放置位置在哪儿以及显示成什么样子这个是由样式来决定的.我们 ...

  2. 常用Git操作

    --------------------git-------------------- 1.简介     1.Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目.[1]  ...

  3. 裸机LCD驱动配置

    横屏4.3寸LCD为480*272(行:480个像素点        列:272个行) 1.1  LCD原理图 : Pin1:Von  电源正(这里由硬件自动控制) Pin2:VM/VDEN 数据使能 ...

  4. Project 10:简单图像的绘制

    目标:绘制如图图像 #include <stdio.h> int main() { int n,i,j,o,k=0; printf("请输入一个数:"); scanf( ...

  5. 4th-结对编程2

    0x00 Coding Coding地址/小伙伴的博客地址 合作伙伴:庞伊凡(201421123011).赵娅汀(201421123012) 0x01 题目描述 上一周大家为四则运算程序设计了2-3个 ...

  6. 团队作业4——第一次项目冲刺(Alpha版本)2nd day

    一.Daily Scrum Meeting照片 二.燃尽图 三.项目进展 界面 1.四个用户登录界面已经完成. 2.界面内的功能完成了一小部分. 登陆部分 1.QQ授权已经申请,还未通过. 2.通过好 ...

  7. 201521123055 《Java程序设计》第3周学习总结

    1. 本章学习总结 2. 书面作业 Q1.代码阅读 public class Test1 { private int i = 1;//这行不能修改 private static int j = 2; ...

  8. 201521123002 《Java程序设计》第2周学习总结

    <Java程序设计>第2周学习总结 1. 本章学习总结 String 1.String类的对象是不可变(immutable)的 2.拼接(+号) "PG"+13; (一 ...

  9. Java课程设计——计算器团队博客

    1.团队名称.团队成员介绍(需要有照片) 1.1团队名称 707 1.2团队成员介绍 谢元将:组长 罗登宇:组员 王华俊:组员 2. 项目git地址 谢元将 罗登宇 王华俊 3. 项目git提交记录截 ...

  10. 201521123066 《Java程序设计》第十二周实验总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2. 书面作业 将Student对象(属性:int id, String name,int age,doubl ...