All pastes #587178 Raw Edit

Untitled

public text v1 · immutable
#587178 ·published 2007-06-24 10:13 UTC
rendered paste body
SPOJ submission 923736 (C) plaintext list. Status: AC, problem SIMREL, contest PAL2007. By bartosz_kula (Bartosz Kula  |  bartosz_kula  |  4  |  109215), 2007-06-18 12:52:26.
/* Bartosz Kula bartosz_kula 4 109215 */
 
/**********************************************************************
* Project : SPOJ SIMREL (c) copyright
* Org     : Gdansk Univeristy of Technology / ETI / group 4
* File    : simrel.c
* Author  : student / Bartosz Kula / 109215 / bartosz_kula(at)o2.pl
* Date    : 18.06.2007
* About   : Przechodnie domkniêcie.
*----------------------------------------------------------------------
* History:                                                             
* ---                                                                  
* Todo:                                                                
* ---                                                                  
***********************************************************************/
#include <stdio.h>
#include <stdlib.h>
 
int compare(const void* ap, const void* bp)
{
   long long int a = *((long long int*)ap);
   long long int b = *((long long int*)bp);
 
   if (a < b)
      return -1;
   else if (a == b)
      return 0;
   else
      return 1;
}  
int main()
{
	long long int k = 0, n = 0, a = 1, i = 0, A[100000];
	scanf("%lld%lld\n", &n, &k);
	for(i = 0; i < n; i++)
		scanf("%lld", &A[i]);
	qsort(A, n, sizeof(long long int), compare);
	a=n;
	for( i = 1; i < n; i++)
	{
		if (A[i] - A[i - 1] < k) 
			a--;
	}
	printf("%lld\n", a);	
return 0; 
}