[백준] P1449

동민·2021년 3월 11일
0
import java.util.Arrays;
import java.util.Scanner;

public class P1449 {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int answer = 0, a[] = new int[sc.nextInt()], k = sc.nextInt();
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		double tape = a[0] - 0.5;
		for (int i = 0; i < a.length; i++) {
			if(tape + k >= a[i] + 0.5) {
				continue;
			}else{
				answer++;
				tape = a[i] - 0.5;
			}
		}

		System.out.println(answer + 1);
		sc.close();

	}
}
profile
BE Developer

0개의 댓글