CF6E.Exposition
普及+/提高
通过率:0%
时间限制:1.50s
内存限制:64MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 h__i. 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)五十岁生日还有几天时间。为此,当地图书馆决定举办一场这位著名科幻作家作品的专题展览。同时决定,展览中仅展出在特定时间段内出版的书籍。显然,如果展出的书籍高度差异过大,参观者将不会满意。因此,组织者认为:展览中最高书籍与最低书籍的高度差不应超过 k 毫米。
图书馆共收藏有 n 卷贝尔伯里的著作,按其出版时间顺序排列。每本书的高度(单位:毫米)已知,记为 hi。由于贝尔伯里在本市备受尊敬,组织者希望在展览中尽可能多地展出他的著作,并由此确定能够覆盖其创作生涯中的哪些时期。请你帮助组织者完成这项艰巨的任务。
输入格式
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 h__i (1 ≤ h__i ≤ 106) is the height of the i-th book in millimeters.
输入数据的第一行包含两个由空格分隔的整数 n(1 ≤ n ≤ 105)和 k(0 ≤ k ≤ 106)——分别表示图书馆中 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.
在输出数据的第一行中,打印两个数字 a 和 b(用空格分隔),其中 a 表示组织者最多能在展览中展出的书籍数量,b 表示满足以下条件的时间段个数:在该时间段内,贝尔伯里出版了恰好 a 本书,且这些书中最高与最低书籍的高度差不超过 k 毫米。
接下来的 b 行中,每行打印两个由空格分隔的整数——分别表示贝尔伯里创作生涯中每个所需时间段的起始卷册编号与终止卷册编号。
输入输出样例
输入#1
3 3 14 12 10
输出#1
2 2 1 2 2 3
输入#2
2 0 10 10
输出#2
2 1 1 2
输入#3
4 5 8 19 10 13
输出#3
2 1 3 4
输入解题思路,AI测评打分。不知道怎么写?