Computer Science, asked by ashanani111, 9 months ago

Given an array of integers A, and an integer K find number of happy elements. Element X is happy if there exists at least 1 element whose difference is less than K i.e. an element X is happy, if there is another element in the range [X-K, X+K] other than X itself. Constraints 1 <= N <= 10^5 0 <= K <= 10^5 0 <= A[i] <= 10^9 Input First line contains two integers N and K where N is size of the array and K is a number as described above Second line contains N integers separated by space. Output Print a single integer denoting the total number of happy elements. Time Limit 1 Examples Example 1 Input 6 3 5 5 7 9 15 2 Output 5 Explanation Other than number 15, everyone has at least 1 element in the range [X-3, X+3]. Hence they are all happy elements. Since these five are in number, the output is 5. Example 2 Input 3 2 1 3 5 Output 3 Explanation All numbers have at least 1 element in the range [X-2, X+2]. Hence they are all happy elements. Since these three are in number, the output is 3.

Answers

Answered by poonamdevi9315257043
0

Answer:

what just I am saying plese tell us

Answered by Anonymous
2

Explanation:

&lt;!DOCTYPE html&gt;</p><p></p><p>&lt;html lang="en"&gt;</p><p></p><p>&lt;head&gt;</p><p></p><p>&lt;title&gt;CUBE&lt;/title&gt;</p><p></p><p>&lt;/head&gt;</p><p></p><p>&lt;body&gt;</p><p></p><p>&lt;div class="container"&gt;</p><p></p><p>&lt;div id="cube"&gt;</p><p></p><p>&lt;div class="front"&gt;My Name is Shariya&lt;/div&gt;</p><p></p><p>&lt;div class="back"&gt;My favourite is Kris wu&lt;/div&gt;</p><p></p><p>&lt;div class="right"&gt;Anime Lover&lt;/div&gt;</p><p></p><p>&lt;div class="left"&gt;Zatch Bell&lt;/div&gt;</p><p></p><p>&lt;div class="top"&gt;=&lt;/div&gt;</p><p></p><p>&lt;div class="bottom"&gt;Code of cube&lt;/div&gt;</p><p></p><p>&lt;/div&gt;</p><p></p><p>&lt;/div&gt;</p><p></p><p>&lt;style&gt;</p><p></p><p>body {</p><p></p><p>padding-left: 30%;</p><p></p><p>padding-top: 5%;</p><p></p><p>}</p><p></p><p>.container {</p><p></p><p>width: 200px;</p><p></p><p>height: 200px;</p><p></p><p>position: relative;</p><p></p><p>-webkit-perspective: 1000px;</p><p></p><p>-moz-perspective: 1000px;</p><p></p><p>}</p><p></p><p>#cube {</p><p></p><p>width: 100%;</p><p></p><p>height: 100%;</p><p></p><p>position: absolute;</p><p></p><p>-webkit-transform-style: preserve-3d;</p><p></p><p>-webkit-animation: rotatecube 10s infinite;</p><p></p><p>-moz-transform-style: preserve-3d;</p><p></p><p>-moz-animation: rotatecube 10s infinite;</p><p></p><p>}</p><p></p><p>#cube div {</p><p></p><p>width: 200px;</p><p></p><p>height: 200px;</p><p></p><p>display: block;</p><p></p><p>position: absolute;</p><p></p><p>border: none;</p><p></p><p>line-height: 200px;</p><p></p><p>text-align: center;</p><p></p><p>font-size: 50px;</p><p></p><p>font-weight: bold;</p><p></p><p>}</p><p></p><p>@-webkit-keyframes rotatecube {</p><p></p><p>0% { -webkit-transform: rotateX(0deg) rotateY(360deg) rotateZ(90deg); }</p><p></p><p>25% { -webkit-transform: rotateX(90deg) rotateY(270deg) rotateZ(180deg); }</p><p></p><p>50% { -webkit-transform: rotateX(180deg) rotateY(180deg) rotateZ(0deg); }</p><p></p><p>75% { -webkit-transform: rotateX(270deg) rotateY(90deg) rotateZ(360deg); }</p><p></p><p>100% { -webkit-transform: rotateX(360deg) rotateY(0deg) rotateZ(270deg); }</p><p></p><p>}</p><p></p><p>@-moz-keyframes rotatecube {</p><p></p><p>0% { -moz-transform: rotateX(0deg) rotateY(360deg) rotateZ(90deg); }</p><p></p><p>25% { -moz-transform: rotateX(90deg) rotateY(270deg) rotateZ(180deg); }</p><p></p><p>50% { -moz-transform: rotateX(180deg) rotateY(180deg) rotateZ(0deg); }</p><p></p><p>75% { -moz-transform: rotateX(270deg) rotateY(90deg) rotateZ(360deg); }</p><p></p><p>100% { -moz-transform: rotateX(360deg) rotateY(0deg) rotateZ(270deg); }</p><p></p><p>}</p><p></p><p>.front {</p><p></p><p>background: rgba(255,0,0,.5);</p><p></p><p>}</p><p></p><p>.back {</p><p></p><p>background: rgba(0,255,0,.5);</p><p></p><p>}</p><p></p><p>.right {</p><p></p><p>background: rgba(0,0,255,.5);</p><p></p><p>}</p><p></p><p>.left {</p><p></p><p>background: rgba(0,255,255,.5);</p><p></p><p>}</p><p></p><p>.top {</p><p></p><p>background: rgba(255,0,255,.5);</p><p></p><p>}</p><p></p><p>.bottom {</p><p></p><p>background: rgba(255,255,0,.5);</p><p></p><p>}</p><p></p><p>#cube .front {</p><p></p><p>-webkit-transform: rotateY(0deg ) translateZ( 100px );</p><p></p><p>-moz-transform: rotateY( 0deg ) translateZ( 100px );</p><p></p><p>}</p><p></p><p>#cube .back {</p><p></p><p>-webkit-transform: rotateX( 180deg ) translateZ( 100px );</p><p></p><p>-moz-transform: rotateX( 180deg ) translateZ( 100px );</p><p></p><p>}</p><p></p><p>#cube .right {</p><p></p><p>-webkit-transform: rotateY( 90deg ) translateZ( 100px );</p><p></p><p>-moz-transform: rotateY( 90deg ) translateZ( 100px );</p><p></p><p>}</p><p></p><p>#cube .left {</p><p></p><p>-webkit-transform: rotateY( -90deg ) translateZ( 100px );</p><p></p><p>-moz-transform: rotateY( -90deg ) translateZ( 100px );</p><p></p><p>}</p><p></p><p>#cube .top {</p><p></p><p>-webkit-transform: rotateX( 90deg ) translateZ( 100px );</p><p></p><p>-moz-transform: rotateX( 90deg ) translateZ( 100px );</p><p></p><p>}</p><p></p><p>#cube .bottom {</p><p></p><p>-webkit-transform: rotateX( -90deg ) translateZ( 100px );</p><p></p><p>-moz-transform: rotateX( -90deg ) translateZ( 100px );</p><p></p><p>}</p><p></p><p>&lt;/style&gt;</p><p></p><p>&lt;/body&gt;</p><p></p><p>&lt;/html&gt;

Similar questions