Anayat And His Girl Friend
All submissions for this problem are available.
Anayat is a Tall and Handsome guy. One day , he decided to make a girl friend. So he announced about being single and interested to be in a relationship. Of course, every girl in college is fond of her and wants to be her girl friend. So they turned out in large number and were all dressed up nicely to impress Anayat. As the girls were large in number and Anayat is also a lazy guy, he decided to skip girls while watching them .He is also a nice guy by heart so he can’t skip more than one girl as it would hurt their ego. To be clear, he will watch the first girl for sure. After watching the girl i , he must either move to i+1 girl or skip ahead to i+2 girl. There is also measure called likeness of each girl which denotes the likeness of Anayat for that girl. We all know that he is lazy so he will stop watching the girls once he encounters his threshold fun level which is denoted by integer ‘d’. Specifically ,he can stop if the difference of the maximum and minimum likeness of girls which he has watched is greater than equal to the threshold level. If this never happens , then he must watch all girls. Later all got to know that he already has a girl friend who was busy that day. So he did all this just to pass his time (wicked guy ;) ).So he just wants to know the minimum number of girls to be watched for him to reach the threshold level.
The first line of the input contains integer ‘T’ denoting the number of test cases. The second line contains 2 integers ‘n’ and ‘d’ denoting the number of girls and the threshold level. The third line follows n integers denoting the likeness of Anayat for girl i.
Output the minimum number of girls which he needs to watch.
- 1 ≤ T ≤ 100
- 1 ≤ n ≤ 100
- 0 ≤ likeness[i] ≤ 1000
- 1 ≤ d ≤ 1000
Input: 3 3 2 1 2 3 5 4 1 2 3 4 5 4 100 10 1 12 101 Output:
Example case 1. He will choose the first 2 girls
Example case 2. He will choose the first three girls
Example case 1. He will choose the first 2 girls,skip the third girl and then choose the fourth girl.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions