02.16 Exposition

Exposition | JXNUOJ

描述:

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.

还有几天就到Berland一位著名作家的50岁生日。因此,当地图书馆决定对这位著名科幻作家的作品进行展览。他们还决定,要将以前只在特殊时期发行的作品放到展览中。很显然,如果作品的大小不一,游客就会不喜欢。这就是为什么组织者认为,最高和最低的展览作品之间不能超过k毫米。

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.

图书馆里有Berlbury的n卷书籍,按发行的时间排序。每本书的高度是已知的,记为hi。因为Berlbury在城市中具有极高地位,所以组织者想要尽可能展览多的书,并找出他们将涵盖哪些时期的书籍。你将帮助组织者解决这些问题。

输入:

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.

第一行包含2个数据(1 ≤ n ≤ 10^5) and k (0 ≤ k ≤ 10^6)——表示图书馆中Berlbury的书籍数,和能接受的最大和最低的书籍的高度差,两个数据用空格隔开。第二行包含n个整数,用空格隔开。每个hi(1 ≤ hi ≤ 106)表示第i本书的高度。

输出:

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.

在第一行输出2个数a和b(用空格分开),a表示组织者能够用于展览的最多数量的书,b表示时期数,这些书籍的最高和最低高度差不超过k毫米。

在接下来的b行分别包含2个整数,用空格分开——Berlbury创造性工作的每个所需时间段的第一卷和最后一卷的索引。

样例输入:

3 3
14 12 10

样例输出:

2 2
1 2
2 3

样例输入:

2 0
10 10

样例输出:

2 1
1 2

样例输入:

4 5
8 19 10 13

样例输出:

2 1
3 4
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值