Codeforces Round #372 (Div. 2) A. Crazy Computer(显示字符)

来源:互联网 发布:手机json格式怎么打开 编辑:程序博客网 时间:2024/04/28 16:31
A. Crazy Computer
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed disappear!

More formally, if you typed a word at second a and then the next word at second b, then if b - a ≤ c, just the new word is appended to other words on the screen. If b - a > c, then everything on the screen disappears and after that the word you have typed appears on the screen.

For example, if c = 5 and you typed words at seconds 1, 3, 8, 14, 19, 20 then at the second 8 there will be 3 words on the screen. After that, everything disappears at the second 13 because nothing was typed. At the seconds 14 and 19 another two words are typed, and finally, at the second 20, one more word is typed, and a total of 3 words remain on the screen.

You're given the times when ZS the Coder typed the words. Determine how many words remain on the screen after he finished typing everything.

Input

The first line contains two integers n and c (1 ≤ n ≤ 100 000, 1 ≤ c ≤ 109) — the number of words ZS the Coder typed and the crazy computer delay respectively.

The next line contains n integers t1, t2, ..., tn (1 ≤ t1 < t2 < ... < tn ≤ 109), where ti denotes the second when ZS the Coder typed the i-th word.

Output

Print a single positive integer, the number of words that remain on the screen after all n words was typed, in other words, at the secondtn.

Examples
input
6 51 3 8 14 19 20
output
3
input
6 11 3 5 7 9 10
output
2
Note

The first sample is already explained in the problem statement.

For the second sample, after typing the first word at the second 1, it disappears because the next word is typed at the second 3 and3 - 1 > 1. Similarly, only 1 word will remain at the second 9. Then, a word is typed at the second 10, so there will be two words on the screen, as the old word won't disappear because 10 - 9 ≤ 1.

给出一串数字,当后一个数字减去前一个数字小于等于所给数字时,可以显示该字符,否则清屏,问屏幕上最后会留多少字符
#include<stdio.h>int main(){__int64 n,m,a[100010],k=0;scanf("%I64d%I64d",&n,&m);for(int i=0;i<n;i++)scanf("%I64d",&a[i]);for(int i=0;i<n-1;i++){if(a[i+1]-a[i]<=m)k++;elsek=0;}printf("%I64d\n",k+1);} 

0 0
原创粉丝点击